Run does not let go Word 
Author Message
 Run does not let go Word

Hi

I have a script that includes the following.  It all works fine, except if I
remove the msgbox.  If I subsequently try to close Word 97, it crashes
(unless I included the msgbox).  I then need to use cntrl/alt/del to close
Word and continue.

MyPath = "P:\Forms\FN007 Review report.doc"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
set WshShell = nothing
msgbox "end"
wscript.quit

Any ideas what is so magical about the msgbox please ?  and what can I do so
that I don't need it.

--
Tom
-------------------------------------
http://www.*-*-*.com/ - Fast access to all the major search engines.
No Ads, Pictures or Banners.



Sat, 10 May 2003 11:57:32 GMT  
 Run does not let go Word
You can try this, maybe it work:

Set WordApp=CreateObject("Word.Application")
WordApp.Documents.Open ("p:\Forms\FN007 Review report.doc")
Set WordApp=Nothing
WordApp.Quit

Greetinx,
Suzanne
(If anyone has any comment: keep it for yourself, I just want to help that's
all, I don't need any advise. If I want advise, I'll ask it)

Quote:
> Hi

> I have a script that includes the following.  It all works fine, except if
I
> remove the msgbox.  If I subsequently try to close Word 97, it crashes
> (unless I included the msgbox).  I then need to use cntrl/alt/del to close
> Word and continue.

> MyPath = "P:\Forms\FN007 Review report.doc"
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.Run ("""" & myPath & """")
> set WshShell = nothing
> msgbox "end"
> wscript.quit

> Any ideas what is so magical about the msgbox please ?  and what can I do
so
> that I don't need it.

> --
> Tom
> -------------------------------------
> http://engines2go.com - Fast access to all the major search engines.
> No Ads, Pictures or Banners.



Sat, 10 May 2003 15:42:50 GMT  
 Run does not let go Word
Thanks for the suggestion, but..
1) the document may not be Word each time, and
2) I only want to close the document when I have finished using it.

I just use the script for searching on the company server to find documents,
then open and work on them.

--
Tom
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.


Quote:
> You can try this, maybe it work:

> Set WordApp=CreateObject("Word.Application")
> WordApp.Documents.Open ("p:\Forms\FN007 Review report.doc")
> Set WordApp=Nothing
> WordApp.Quit

> Greetinx,
> Suzanne
> (If anyone has any comment: keep it for yourself, I just want to help
that's
> all, I don't need any advise. If I want advise, I'll ask it)


> > Hi

> > I have a script that includes the following.  It all works fine, except
if
> I
> > remove the msgbox.  If I subsequently try to close Word 97, it crashes
> > (unless I included the msgbox).  I then need to use cntrl/alt/del to
close
> > Word and continue.

> > MyPath = "P:\Forms\FN007 Review report.doc"
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.Run ("""" & myPath & """")
> > set WshShell = nothing
> > msgbox "end"
> > wscript.quit

> > Any ideas what is so magical about the msgbox please ?  and what can I
do
> so
> > that I don't need it.

> > --
> > Tom
> > -------------------------------------
> > http://engines2go.com - Fast access to all the major search engines.
> > No Ads, Pictures or Banners.



Sat, 10 May 2003 03:00:00 GMT  
 Run does not let go Word

Quote:

> Hi

> I have a script that includes the following.  It all works fine, except if I
> remove the msgbox.  If I subsequently try to close Word 97, it crashes
> (unless I included the msgbox).  I then need to use cntrl/alt/del to close
> Word and continue.

> MyPath = "P:\Forms\FN007 Review report.doc"
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.Run ("""" & myPath & """")
> set WshShell = nothing
> msgbox "end"
> wscript.quit

> Any ideas what is so magical about the msgbox please ?  and what can
> I do so that I don't need it.

> --
> Tom
> -------------------------------------
> http://engines2go.com - Fast access to all the major search engines.
> No Ads, Pictures or Banners.

My guess is that you are removing the attachment to the WshShell object
before the Run method has been released from it's job to start the Word
document.  You can either use an open ended delay (WSH.Sleep 2000) in
place of the MsgBox or use a Do Until loop to check for the loading of
the Word document ...

MyPath = "P:\Forms\FN007 Review report.doc"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
Do Until WshShell.AppActivate "FN007 Review report.doc"
  wsh.sleep 100
Loop
set WshShell = nothing
wscript.quit

You might want a limit count in that loop, in case there is an
unexpected fault in loading the document.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Sat, 10 May 2003 03:00:00 GMT  
 Run does not let go Word

Thanks Tom

WshShell.AppActivate  cased me errors which I couldn't fix...
but simply inserting a sleep 2000 seems to work - so I will leave it at
that.

Thanks

--
Tom
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.


Quote:

> > Hi

> > I have a script that includes the following.  It all works fine, except
if I
> > remove the msgbox.  If I subsequently try to close Word 97, it crashes
> > (unless I included the msgbox).  I then need to use cntrl/alt/del to
close
> > Word and continue.

> > MyPath = "P:\Forms\FN007 Review report.doc"
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.Run ("""" & myPath & """")
> > set WshShell = nothing
> > msgbox "end"
> > wscript.quit

> > Any ideas what is so magical about the msgbox please ?  and what can
> > I do so that I don't need it.

> > --
> > Tom
> > -------------------------------------
> > http://engines2go.com - Fast access to all the major search engines.
> > No Ads, Pictures or Banners.

> My guess is that you are removing the attachment to the WshShell object
> before the Run method has been released from it's job to start the Word
> document.  You can either use an open ended delay (WSH.Sleep 2000) in
> place of the MsgBox or use a Do Until loop to check for the loading of
> the Word document ...

> MyPath = "P:\Forms\FN007 Review report.doc"
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.Run ("""" & myPath & """")
> Do Until WshShell.AppActivate "FN007 Review report.doc"
>   wsh.sleep 100
> Loop
> set WshShell = nothing
> wscript.quit

> You might want a limit count in that loop, in case there is an
> unexpected fault in loading the document.

> Tom Lavedas
> -----------
> http://www.pressroom.com/~tglbatch/



Sun, 11 May 2003 12:28:29 GMT  
 Run does not let go Word
What errors?  It sure should work.

Though the open ended Sleep approach is not too much of a problem in
this particular application, I'm still curious about the errors.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Quote:

> Thanks Tom

> WshShell.AppActivate  cased me errors which I couldn't fix...
> but simply inserting a sleep 2000 seems to work - so I will leave it
> at that.

> Thanks

> --
> Tom
> -------------------------------------
> http://engines2go.com - Fast access to all the major search engines.
> No Ads, Pictures or Banners.




> > > Hi

> > > I have a script that includes the following.  It all works fine, except
> if I
> > > remove the msgbox.  If I subsequently try to close Word 97, it crashes
> > > (unless I included the msgbox).  I then need to use cntrl/alt/del to
> close
> > > Word and continue.

> > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > WshShell.Run ("""" & myPath & """")
> > > set WshShell = nothing
> > > msgbox "end"
> > > wscript.quit

> > > Any ideas what is so magical about the msgbox please ?  and what can
> > > I do so that I don't need it.

> > > --
> > > Tom
> > > -------------------------------------
> > > http://engines2go.com - Fast access to all the major search engines.
> > > No Ads, Pictures or Banners.

> > My guess is that you are removing the attachment to the WshShell object
> > before the Run method has been released from it's job to start the Word
> > document.  You can either use an open ended delay (WSH.Sleep 2000) in
> > place of the MsgBox or use a Do Until loop to check for the loading of
> > the Word document ...

> > MyPath = "P:\Forms\FN007 Review report.doc"
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.Run ("""" & myPath & """")
> > Do Until WshShell.AppActivate "FN007 Review report.doc"
> >   wsh.sleep 100
> > Loop
> > set WshShell = nothing
> > wscript.quit

> > You might want a limit count in that loop, in case there is an
> > unexpected fault in loading the document.

> > Tom Lavedas
> > -----------
> > http://www.pressroom.com/~tglbatch/



Sun, 11 May 2003 03:00:00 GMT  
 Run does not let go Word
Mea Culpa.  I see the problem - missing parentheses in a function call
to AppActivate.  There was an error in my original example.  Try ...

MyPath = "E:\Tom\Musicmatch.doc"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
Do Until WshShell.AppActivate("Musicmatch.doc")
  Wscript.sleep 100
Loop
set WshShell = nothing
wscript.quit

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Quote:

> Hi Tom (thanks for your interest)

> MyPath = "E:\Tom\Musicmatch.doc"
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.Run ("""" & myPath & """")
> Do Until WshShell.AppActivate "Musicmatch.doc"
>   Wscript.sleep 100
> Loop
> set WshShell = nothing
> wscript.quit

> Gives error... Expected statement.

> MyPath = "E:\Tom\Musicmatch.doc"
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.Run ("""" & myPath & """")
> Do Until WshShell.AppActivate MyPath
>   Wscript.sleep 100
> Loop
> set WshShell = nothing
> wscript.quit

> Gives me error...
> Wrong number of arguments or invalid property assignment:
> 'WshShell.AppActivate'

> --
> Tom
> -------------------------------------
> http://engines2go.com - Fast access to all the major search engines.
> No Ads, Pictures or Banners.



> > What errors?  It sure should work.

> > Though the open ended Sleep approach is not too much of a problem in
> > this particular application, I'm still curious about the errors.

> > Tom Lavedas
> > -----------
> > http://www.pressroom.com/~tglbatch/


> > > Thanks Tom

> > > WshShell.AppActivate  cased me errors which I couldn't fix...
> > > but simply inserting a sleep 2000 seems to work - so I will leave it
> > > at that.

> > > Thanks

> > > --
> > > Tom
> > > -------------------------------------
> > > http://engines2go.com - Fast access to all the major search engines.
> > > No Ads, Pictures or Banners.




> > > > > Hi

> > > > > I have a script that includes the following.  It all works fine,
> except
> > > if I
> > > > > remove the msgbox.  If I subsequently try to close Word 97, it
> crashes
> > > > > (unless I included the msgbox).  I then need to use cntrl/alt/del to
> > > close
> > > > > Word and continue.

> > > > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > > > WshShell.Run ("""" & myPath & """")
> > > > > set WshShell = nothing
> > > > > msgbox "end"
> > > > > wscript.quit

> > > > > Any ideas what is so magical about the msgbox please ?  and what can
> > > > > I do so that I don't need it.

> > > > > --
> > > > > Tom
> > > > > -------------------------------------
> > > > > http://engines2go.com - Fast access to all the major search engines.
> > > > > No Ads, Pictures or Banners.

> > > > My guess is that you are removing the attachment to the WshShell
> object
> > > > before the Run method has been released from it's job to start the
> Word
> > > > document.  You can either use an open ended delay (WSH.Sleep 2000) in
> > > > place of the MsgBox or use a Do Until loop to check for the loading of
> > > > the Word document ...

> > > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > > WshShell.Run ("""" & myPath & """")
> > > > Do Until WshShell.AppActivate "FN007 Review report.doc"
> > > >   wsh.sleep 100
> > > > Loop
> > > > set WshShell = nothing
> > > > wscript.quit

> > > > You might want a limit count in that loop, in case there is an
> > > > unexpected fault in loading the document.

> > > > Tom Lavedas
> > > > -----------
> > > > http://www.pressroom.com/~tglbatch/



Sun, 11 May 2003 03:00:00 GMT  
 Run does not let go Word
Hi Tom (thanks for your interest)

MyPath = "E:\Tom\Musicmatch.doc"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
Do Until WshShell.AppActivate "Musicmatch.doc"
  Wscript.sleep 100
Loop
set WshShell = nothing
wscript.quit

Gives error... Expected statement.

MyPath = "E:\Tom\Musicmatch.doc"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
Do Until WshShell.AppActivate MyPath
  Wscript.sleep 100
Loop
set WshShell = nothing
wscript.quit

Gives me error...
Wrong number of arguments or invalid property assignment:
'WshShell.AppActivate'

--
Tom
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.


Quote:
> What errors?  It sure should work.

> Though the open ended Sleep approach is not too much of a problem in
> this particular application, I'm still curious about the errors.

> Tom Lavedas
> -----------
> http://www.pressroom.com/~tglbatch/


> > Thanks Tom

> > WshShell.AppActivate  cased me errors which I couldn't fix...
> > but simply inserting a sleep 2000 seems to work - so I will leave it
> > at that.

> > Thanks

> > --
> > Tom
> > -------------------------------------
> > http://engines2go.com - Fast access to all the major search engines.
> > No Ads, Pictures or Banners.




> > > > Hi

> > > > I have a script that includes the following.  It all works fine,
except
> > if I
> > > > remove the msgbox.  If I subsequently try to close Word 97, it
crashes
> > > > (unless I included the msgbox).  I then need to use cntrl/alt/del to
> > close
> > > > Word and continue.

> > > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > > WshShell.Run ("""" & myPath & """")
> > > > set WshShell = nothing
> > > > msgbox "end"
> > > > wscript.quit

> > > > Any ideas what is so magical about the msgbox please ?  and what can
> > > > I do so that I don't need it.

> > > > --
> > > > Tom
> > > > -------------------------------------
> > > > http://engines2go.com - Fast access to all the major search engines.
> > > > No Ads, Pictures or Banners.

> > > My guess is that you are removing the attachment to the WshShell
object
> > > before the Run method has been released from it's job to start the
Word
> > > document.  You can either use an open ended delay (WSH.Sleep 2000) in
> > > place of the MsgBox or use a Do Until loop to check for the loading of
> > > the Word document ...

> > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > WshShell.Run ("""" & myPath & """")
> > > Do Until WshShell.AppActivate "FN007 Review report.doc"
> > >   wsh.sleep 100
> > > Loop
> > > set WshShell = nothing
> > > wscript.quit

> > > You might want a limit count in that loop, in case there is an
> > > unexpected fault in loading the document.

> > > Tom Lavedas
> > > -----------
> > > http://www.pressroom.com/~tglbatch/



Mon, 12 May 2003 01:29:34 GMT  
 Run does not let go Word
Tom thanks

Appreciate the extra help...
It works fine now :-)

--
Tom
------------------------------------
http://cheqsoft.com    My site


Quote:
> Mea Culpa.  I see the problem - missing parentheses in a function call
> to AppActivate.  There was an error in my original example.  Try ...

> MyPath = "E:\Tom\Musicmatch.doc"
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.Run ("""" & myPath & """")
> Do Until WshShell.AppActivate("Musicmatch.doc")
>   Wscript.sleep 100
> Loop
> set WshShell = nothing
> wscript.quit

> Tom Lavedas
> -----------
> http://www.pressroom.com/~tglbatch/


> > Hi Tom (thanks for your interest)

> > MyPath = "E:\Tom\Musicmatch.doc"
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.Run ("""" & myPath & """")
> > Do Until WshShell.AppActivate "Musicmatch.doc"
> >   Wscript.sleep 100
> > Loop
> > set WshShell = nothing
> > wscript.quit

> > Gives error... Expected statement.

> > MyPath = "E:\Tom\Musicmatch.doc"
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> > WshShell.Run ("""" & myPath & """")
> > Do Until WshShell.AppActivate MyPath
> >   Wscript.sleep 100
> > Loop
> > set WshShell = nothing
> > wscript.quit

> > Gives me error...
> > Wrong number of arguments or invalid property assignment:
> > 'WshShell.AppActivate'

> > --
> > Tom
> > -------------------------------------
> > http://engines2go.com - Fast access to all the major search engines.
> > No Ads, Pictures or Banners.



> > > What errors?  It sure should work.

> > > Though the open ended Sleep approach is not too much of a problem in
> > > this particular application, I'm still curious about the errors.

> > > Tom Lavedas
> > > -----------
> > > http://www.pressroom.com/~tglbatch/


> > > > Thanks Tom

> > > > WshShell.AppActivate  cased me errors which I couldn't fix...
> > > > but simply inserting a sleep 2000 seems to work - so I will leave it
> > > > at that.

> > > > Thanks

> > > > --
> > > > Tom
> > > > -------------------------------------
> > > > http://engines2go.com - Fast access to all the major search engines.
> > > > No Ads, Pictures or Banners.




> > > > > > Hi

> > > > > > I have a script that includes the following.  It all works fine,
> > except
> > > > if I
> > > > > > remove the msgbox.  If I subsequently try to close Word 97, it
> > crashes
> > > > > > (unless I included the msgbox).  I then need to use
cntrl/alt/del to
> > > > close
> > > > > > Word and continue.

> > > > > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > > > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > > > > WshShell.Run ("""" & myPath & """")
> > > > > > set WshShell = nothing
> > > > > > msgbox "end"
> > > > > > wscript.quit

> > > > > > Any ideas what is so magical about the msgbox please ?  and what
can
> > > > > > I do so that I don't need it.

> > > > > > --
> > > > > > Tom
> > > > > > -------------------------------------
> > > > > > http://engines2go.com - Fast access to all the major search
engines.
> > > > > > No Ads, Pictures or Banners.

> > > > > My guess is that you are removing the attachment to the WshShell
> > object
> > > > > before the Run method has been released from it's job to start the
> > Word
> > > > > document.  You can either use an open ended delay (WSH.Sleep 2000)
in
> > > > > place of the MsgBox or use a Do Until loop to check for the
loading of
> > > > > the Word document ...

> > > > > MyPath = "P:\Forms\FN007 Review report.doc"
> > > > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > > > WshShell.Run ("""" & myPath & """")
> > > > > Do Until WshShell.AppActivate "FN007 Review report.doc"
> > > > >   wsh.sleep 100
> > > > > Loop
> > > > > set WshShell = nothing
> > > > > wscript.quit

> > > > > You might want a limit count in that loop, in case there is an
> > > > > unexpected fault in loading the document.

> > > > > Tom Lavedas
> > > > > -----------
> > > > > http://www.pressroom.com/~tglbatch/



Mon, 12 May 2003 12:11:21 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Word won't let go of Excel?

2. HELP - Graphics Server Not Letting Go!!

3. Let Word run a macro from within Excel?

4. Not running, am I doing something wrong

5. Letting one prosess be done before starting the next one

6. Data Control Won't Let Go...

7. Make VB let go of Excel?

8. HScroll in User Control wont let go

9. Focus Won't Let Go (VB4.0)

10. LET ME EXPLAIN MYSELF NOW--this has gone on long enough

11. Letting go of a DLL ?

12. VB Won't Let Go

 

 
Powered by phpBB® Forum Software