Discussion:
[python-win32] Call was rejected by callee.
Andrew C
15 years ago
Permalink
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
Paul Keating
15 years ago
Permalink
Post by Andrew C
objDoc.Content.Font.Name = "Arial" # <--- fails here
It ought to work.

Switch Visible on so that you can see what is happening as you step through
the code. I suspect that Word is popping up a dialogue box (about recovered
files, perhaps) that you cannot see, and is refusing to do some things until
the popup is dismissed.

If that doesn't help, check that objDoc.Content is returning what you think
it does.


----- Original Message -----
From: Andrew C

Loading...