General information
Category:
COM/DCOM and OLE Automation
Title:
Error automating Word: OLE IDispatch exception code 0...
I am using VFP 6.0 SP3 to automate Word 97 SR2. I periodically get the error message “OLE IDispatch exception code 0 from MSWord. Object has been deleted.”
The code is running through the FormFields collection with code like
* oAD is a pointer to the ActiveDocument
for each oField in oAD.FormFields
cFieldName = oField.Name
endfor
What makes this odd is that I actually do this twice. I open a specific Word document, scan through the collection of bookmarks/fields and stuff them with values from a table. I then activate Word and let the user fill in any missing field values. When they return to VFP I run through the collection again saving their entries.
The first time works fine, the second generates the error message.
I can also reference the Word field objects by the syntax oAD.FormFields[nIndex] and when I do that I find that out of the 53 fields in the collections I can reference the fields at location 1, and 25-53. The fields between 2 and 24 all generate the error message.
Any suggestions would be appreciated.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only