WScript.GetObject doesn't get running Word App 
Author Message
 WScript.GetObject doesn't get running Word App

My environment:
Windows NT 4.0 SP6a, WSH 5.6

My problem:
I have a running Word (document), i.e. one instance of winword.exe. Now
the following VBS Script within WSH should allow me to do some event
handling:

SUB WordEventDocumentChange()
   CALL MsgBox ("Event fired")
END SUB

SET MyApp = WScript.GetObject("","Word.Application","WordEvent")

DO WHILE TRUE
   WScript.Sleep (1000)
LOOP

When I execute the Script the running Word (object) isn't selected but
an addtional instance of winword.exe is started (TaskMgr). Also Clicking
in the original running word window doesn't fire the MsgBox. So it seems
that the WScript.GetObject Method can't reuse the running application
but always starts a new instance.
(If I WScript.CreateObject a new instance with an Event Prefix, the
event fires.)

Any hints?
Thansk, Gnther



Mon, 08 Aug 2005 19:42:43 GMT  
 WScript.GetObject doesn't get running Word App
It's due to a peculiarity of the Wscript syntax for GetObject.  The
first argument must be absent, not empty for it to work.  Take out the
blank string ("") from the first argument and it should work fine.

Tom Lavedas
===========

Quote:

> My environment:
> Windows NT 4.0 SP6a, WSH 5.6

> My problem:
> I have a running Word (document), i.e. one instance of winword.exe. Now
> the following VBS Script within WSH should allow me to do some event
> handling:

> SUB WordEventDocumentChange()
>    CALL MsgBox ("Event fired")
> END SUB

Take out the double quote marks.  

 SET MyApp = WScript.GetObject(,"Word.Application","WordEvent")

Quote:
> DO WHILE TRUE
>    WScript.Sleep (1000)
> LOOP

> When I execute the Script the running Word (object) isn't selected but
> an addtional instance of winword.exe is started (TaskMgr). Also Clicking
> in the original running word window doesn't fire the MsgBox. So it seems
> that the WScript.GetObject Method can't reuse the running application
> but always starts a new instance.
> (If I WScript.CreateObject a new instance with an Event Prefix, the
> event fires.)

> Any hints?
> Thansk, Gnther



Tue, 09 Aug 2005 02:27:53 GMT  
 WScript.GetObject doesn't get running Word App

Quote:
> SUB WordEventDocumentChange()
>    CALL MsgBox ("Event fired")
> END SUB

SET MyApp = GetObject(,"Word.Application")
CALL WScript.ConnectObject(MyApp,"WordEvent")

Quote:
> DO WHILE TRUE
>    WScript.Sleep (1000)
> LOOP

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp



Tue, 09 Aug 2005 08:54:28 GMT  
 WScript.GetObject doesn't get running Word App
That creates an error on my machine. The documentation also says that for the METHOD GetObject it
must not be omitted. What to do?

Gnther

Tom Lavedas schrieb:

Quote:
> It's due to a peculiarity of the Wscript syntax for GetObject.  The
> first argument must be absent, not empty for it to work.  Take out the
> blank string ("") from the first argument and it should work fine.

> Tom Lavedas
> ===========


> > My environment:
> > Windows NT 4.0 SP6a, WSH 5.6

> > My problem:
> > I have a running Word (document), i.e. one instance of winword.exe. Now
> > the following VBS Script within WSH should allow me to do some event
> > handling:

> > SUB WordEventDocumentChange()
> >    CALL MsgBox ("Event fired")
> > END SUB

> Take out the double quote marks.

>  SET MyApp = WScript.GetObject(,"Word.Application","WordEvent")

> > DO WHILE TRUE
> >    WScript.Sleep (1000)
> > LOOP

> > When I execute the Script the running Word (object) isn't selected but
> > an addtional instance of winword.exe is started (TaskMgr). Also Clicking
> > in the original running word window doesn't fire the MsgBox. So it seems
> > that the WScript.GetObject Method can't reuse the running application
> > but always starts a new instance.
> > (If I WScript.CreateObject a new instance with an Event Prefix, the
> > event fires.)

> > Any hints?
> > Thansk, Gnther



Tue, 09 Aug 2005 17:26:41 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. WScript.GetObject doesn't get running Word App

2. WScript.Shell Run Doesn't Work???

3. Wscript.shell Run doesn't work

4. VB 4 app doesn't want to run under Win 3.x Help Please

5. Strange Problem Help Required CR doesn't show in 16bit VB app Running on NT

6. my VB6 app doesn't run without msvbvm60.dll

7. my VB6 app doesn't run without msvbvm60.dll

8. Word 2002 doesn't run Word2K template/macros

9. Macro doesn't run under Word 2000

10. GetObject() in VBScript on web page doesn't work

11. GetObject() in VBScript on web page doesn't work

12. GetObject doesn't work from VBScript

 

 
Powered by phpBB® Forum Software