Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
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.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement