Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation Fails...
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01094192
Message ID:
01094201
Views:
9
>Using Word 2003. Can anyone explain why the following works when executed from the Command Window ...
>oWord = newobject('word.application')           && returns an object
>oDoc = oWord.Documents.Open('WorkingFile.doc')  && returns an object
>loRange = oWord.ActiveDocument.Range(0,0)       && returns an object
>loRange.Find.Execute('OldVal', , , , , , .T., , , 'NewVal', , , , 2) && returns .T.
>oWord.Visible = .T. && I can visually verify the replace occured
>
>... but fails when I run it from a PRG? The only difference is the code above is in a PRG class and all the variables are now properties of the class (e.g., THIS.oWord, THIS.oDocument). loRange is just a variable created in a method.

Try oDoc = oWord.Documents.Open(getf('doc'))
if that works, it's a pathing problem to the document. You may need the fully qualified path.
John Harvey
Shelbynet.com

"I'm addicted to placebos. I could quit, but it wouldn't matter." Stephen Wright
Previous
Reply
Map
View

Click here to load this message in the networking platform