Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

how to check that MS Word is running using VBScript

$
0
0

we have an application that runs MS Word (hidden) to print documents.

If one of the printers has a problem, then Word hangs while waiting for the spooler to return the 'queued' message.

We have found that if we make Word visible (by using VBA in Excel with GetObject andoWordApp.visible=true for example) then the process continues printing the other documents with no problem.

We would like to make this more automatic by having a VBScript check for Word in running processes, if it finds it, make it visible, wait for a few seconds, hide it, and quit...

But I have a problem that the VBScript GetObject function instantiates Word if it's not already running.

how should I check that word is running using VBScript without creating an instance of it?

here is the code I have in my VBScript file:

dim oWord, WScriptShell

set oWord = getobject("", "Word.Application")
set WScriptShell = CreateObject("WScript.Shell")

if isobject(oWord)  then 'and oWord.Documents.count>0
    wscript.echo("Word is running")
    oWord.visible=true
    WScript.Sleep 1000
    oWord.visible=false
else
    wscript.echo("Word not running")
end if

so what should I use to check if word is running without creating an instance of it?



Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>