Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Barbara Peisch
  Where is Barbara Peisch?
 Oceanside
 California - United States
 Barbara Peisch
 To: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
Subject: RE: Getobject / Createobject
Thread ID: 183878 Message ID: 183931 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Wednesday, July 16, 2008 4:47:46 AM         
   



> >
> > What I would do is use GETOBJECT() just to determine if there's a Word instance open, but then use CREATEOBJECT() to get your own instance. Only close Word completely if there wasn't an instance open to start with. (You might want to check if that instance is still around at the end of your process.)
> >
> > -BP
> > www.peisch.com
>
>
> YOUSFI BENAMEUR
> Is there some word existing instance (object oWord) destroy it
>
  IF Vartype(oWord)="O" 
>        oWord=null
>        ENDIF
> 

> oWord is public
> and you start your createObject("Word.application")....
> Regards

I would advise against this for a couple of reasons:

1. Use of a public variable here is a bad idea. What if you have a different part of your program that also automates Word and used the same public variable? You could adversely affect that part of the program if the user was running something else in a different form or menu option.

2. If a user has an instance of Word open for something that has nothing to do with your app, closing it without their permission or knowledge would be a horrible thing to do to them.

-BP
www.peisch.com

ENTIRE THREAD

Getobject / Createobject Posted by Hans de Groot @ 7/15/2008 5:53:45 PM
RE: Getobject / Createobject Posted by Barbara Peisch @ 7/15/2008 8:41:43 PM
RE: Getobject / Createobject Posted by Yousfi Benameur @ 7/16/2008 3:17:15 AM
RE: Getobject / Createobject Posted by Barbara Peisch @ 7/16/2008 4:47:46 AM
RE: Getobject / Createobject Posted by Yousfi Benameur @ 7/16/2008 8:06:03 PM
RE: Getobject / Createobject Posted by Barbara Peisch @ 7/16/2008 9:44:03 PM
RE: Getobject / Createobject Posted by Hans de Groot @ 7/16/2008 6:59:00 AM
RE: Getobject / Createobject Posted by Yousfi Benameur @ 7/16/2008 8:26:48 AM
RE: Getobject / Createobject Posted by Christof Wollenhaupt @ 7/16/2008 10:51:35 AM
RE: Getobject / Createobject Posted by Koen Piller @ 7/17/2008 9:34:02 AM
RE: Getobject / Createobject Posted by Hans de Groot @ 8/8/2008 10:49:34 AM
RE: Getobject / Createobject Posted by Yousfi Benameur @ 8/8/2008 11:38:08 AM