Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation - avoiding 2 copies of Word
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00748221
Message ID:
00748250
Views:
14
Also, on top of what Marcia said, you should be careful of using GetObject() because if the user has a copy of word open, you'll end up using that copy. Then when you close it (assuming at some point you want to close your instantiation), you'll close the user's copy. Your user might find this annoying.

You might want to try setting a flag, so that the first time you click the button you use CreateObject() and set the flag to true, and each subsequent click will use GetObject(). Reset the flag when you close the instantiation of word.

Alan

>I made my first attempt at starting word from VFP7, works fine except if the code [following] is started twice from the button on the form, I get two copies of Word starting, not a second document window within Word. I got the code from a web site, and don't have time right now to understand what I am doing, just need to get a demo up by tomorrow.
>
>Also I just want to stick stuff at the end of the text, then let the user modify and save the document - that works, but I end up with all the text highlighted.
>
>#DEFINE wdStory 6
>loWord = CREATEOBJECT("Word.Application")
>loWord.Visible = .T.
>loDocument = loWord.Documents.Add("template/dot name")
>loSelection = loWord.Selection
>loSelection.MoveEnd(wdStory)
>* repeat following as required
>loSelection.InsertAfter(---some text----)
>loSelection.InsertAfter(CHR(13))
Previous
Reply
Map
View

Click here to load this message in the networking platform