Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question about Word Automation
Message
 
À
31/10/2001 08:35:26
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00574981
Message ID:
00575736
Vues:
23
I had this situation with the upgrade from Word95 to Word97 (and 97 to 2000) on some systems only. What seems to happen (and you can see it if you double-click on a file by hand) is that the createObject() call returns when Word is only partly instantiated OR when it is intantiated but has not fully loaded the file.
I found the best way around it to be something like:
** Word 97 causes a problem - shellEx returns too quickly 
** causing getObject to fail ( the object isn't fully loaded).
** we'll try a number of times and then fail...

oldEHandler = on("error")
eCode = 0
nRetries = 0
* an error will set eCode to non-zero...
on error eCode = error()

veryTopWord = getObject(theFile)
do while (nRetries < SW_WordRetries) and (eCode <> 0)
	statusMsg("Retrying Word communication...")
	doEvents
	eCode = 0
	veryTopWord = getObject(theFile)
	nRetries = nRetries+1
	doEvents
	=inkey(SW_wordRetrySecs)
	doEvents
endDo
		
if type("veryTopWord") <> "O"
  oopsMsg("Sorry, I was unable to launch Word for this document [1].")
  thisForm.killFile(theFile)
  return
endif
>I also have a problem automating word from VFP 7.0.
>
>After the wObj.createobject("word.application") line i issue
>wObj.documents.open("name of a document")
>
>this causes an ole error "server caused an exception"
>I i put a timeout before the open document line there is no problem.
>Also similar code has been used throughout our applications successfully using foxpro 5.0 and 6.0.
>
>Any ideas?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform