Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get my own copy of Word?
Message
From
22/11/2000 10:29:43
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00444424
Message ID:
00444618
Views:
7
>This still doesn't address the problem of someone coming in during your processing after you have obtained a reference to Word using Createobject. You created an instance of Word. When a user launches Word while you have it open, they get your instance. Because you opened it with Createobject(), you think you can close it, but that will interfere with other things.
>
>Always use createobject to initially get your instance. Even if Word is open, a new instance will be created. However, instead of just exiting out of Word, check the Documents.Count property first. If it is greater than 1 (the document you are working on) then you know to only set your variable to .NULL. and not call Quit first because someone else is using Word to do something.


Knowing that createobject creates my own instance helps a lot. Sure seems like there ought to be a way to create an instance of an application and tell the OS to keep it private. I've noticed in the past that some apps, like VFP, start a new instance if I start them (say) from a shortcut and others, like Word, use an open instance if it's available. Given that this behavior changes, I think it's fair to presume there's a means of controlling it.

>The only (as I see it) issue that this doesn't correct is the problem of someone going into Word while you have it open and then they close it before you are done your processing. If they do that, then Word is closed and you lose your object reference. I don't know if there is a chance of this happening during the process you described.

The only way for this to happen is if some other independently running app does the above programmatically, and that's not likely to happen in the environment I'm developing my app for. Still, I don't like leaving subtle gotchas like this around for someone to trip over in the future.

Thanks for the help
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum
Previous
Reply
Map
View

Click here to load this message in the networking platform