I am working on encryption/decrypt Logic based program. The requirement is such that I have launch required document/image thr' VB, so I am using WshShell.Run to lauch the required App.
WshShell.Run has an argument blnWaitOnReturn, I am keeping this True since I want to know when user finishes editing lauched document/image etc. This works fine if the application required by the document for e.g. Word is not already running. If its running for some other document etc , blnWaitOnReturn has no effect.
The control is immediately returned to the calling program and my purpose is defeated , infact creating other problems.
I am locking the my program when user lauches some document and enabling same when he is back to application closing the lauched application.
This does not happen if suppose Word is already opened and I am lauching thr' my program.

Can anyone help in this , any guidance, suggestions appreciated.

I am using VB 6.0 on Win98/Win2k, I registed wshom.ocx , version 5.0.531.7.

Launching applications like Word, Excel, Adobe Acrobat Writer/Reader etc.


One Possible Solution, is to check and see if the app is already running. If it is, in fact, Word that is giving you grief, you could use a timer, for example, and search to see if the classname is open.... In a code module, add this:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Then in your timer, or whenever you want to check for word, you can simple call findwindow on the classname of word, and if findwindow returns 1, then you know word is open... the class of word is: OpusApp, for Word Xp... You can run this little tool I built to grab the classname of just about any window from here:

The Source to search to see if word is running, would be something like this:

retval = findwindow("OpusApp", vbnullstring)
if retval <> 0 then
     msgbox "Found Word"
end if

You can then check to see if it's open at any time, so that way you know what the default behavior is going to be. You might also consider looking into using the word.application class, and instantiate an instance of it for your app.... You can spawn word like this:

Dim Word
Set Word = CreateObject("Word.Application")
Set doc = Word.Documents.Add("c:\path2worddoc\somedocument.doc")
Word.Visible = True

There are other methods that work with the Word and Doc object.... a bunch of methods and a bunch of properties...here is the resource for the methods and properties associated with the word object:

I hope this helps some....

This article has been dead for over six months. Start a new discussion instead.