Andrew C
15 years ago
I have a script on my server that is performing a win32com operation to generate a MS Word document, and I am getting an error stating: (-2147418111, 'Call was rejected by callee', None,None).
How can I get around this error? What can cause it?
I am using python 2.6. Code below
Thanks
AC
def CreateWordDocument(bodyText,graphicsPath, FileName):
# create word application
objWord = win32.gencache.EnsureDispatch('Word.Application')
# don't show program
objWord.Visible = False
#create new word doc
objDoc = objWord.Documents.Add()
# format the text style
objDoc.Content.Font.Name = "Arial" # <--- fails here
objDoc.Content.Font.Bold = 1 # <--- fails here
objDoc.Content.Font.Size = 12 # <--- fails here
# write information
objSelection = objWord.Selection
objSelection.TypeText(bodyText[0])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[0], False, True)
objSelection.TypeParagraph()
objSelection.TypeText(bodyText[1])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[1], False, True)
objSelection.TypeParagraph()
objSelection.TypeText(bodyText[2])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[2], False, True)
objSelection.TypeParagraph()
objSelection.TypeText(bodyText[3])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[3], False, True)
objSelection.TypeParagraph()
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
How can I get around this error? What can cause it?
I am using python 2.6. Code below
Thanks
AC
def CreateWordDocument(bodyText,graphicsPath, FileName):
# create word application
objWord = win32.gencache.EnsureDispatch('Word.Application')
# don't show program
objWord.Visible = False
#create new word doc
objDoc = objWord.Documents.Add()
# format the text style
objDoc.Content.Font.Name = "Arial" # <--- fails here
objDoc.Content.Font.Bold = 1 # <--- fails here
objDoc.Content.Font.Size = 12 # <--- fails here
# write information
objSelection = objWord.Selection
objSelection.TypeText(bodyText[0])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[0], False, True)
objSelection.TypeParagraph()
objSelection.TypeText(bodyText[1])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[1], False, True)
objSelection.TypeParagraph()
objSelection.TypeText(bodyText[2])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[2], False, True)
objSelection.TypeParagraph()
objSelection.TypeText(bodyText[3])
objSelection.TypeParagraph()
objShape = objSelection.InlineShapes.AddPicture(graphicsPath[3], False, True)
objSelection.TypeParagraph()
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4