| | |
blnWaitOnReturn of wshShell.Run has no effect if required application is already runn
![]() |
•
•
Join Date: Mar 2005
Posts: 40
Reputation:
Solved Threads: 0
blnWaitOnReturn of wshShell.Run has no effect if required application is already runn
0
#1 Jun 9th, 2005
Hello,
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.
Regards
[Sham]
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.
Regards
[Sham]
Re: blnWaitOnReturn of wshShell.Run has no effect if required application is already runn
0
#2 Jun 9th, 2005
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:
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:
http://www.aftermath.net/~coma/downloads/getclass/
The Source to search to see if word is running, would be something like this:
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:
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:
http://msdn.microsoft.com/library/de...tionobject.asp
I hope this helps some....
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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:
http://www.aftermath.net/~coma/downloads/getclass/
The Source to search to see if word is running, would be something like this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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:
http://msdn.microsoft.com/library/de...tionobject.asp
I hope this helps some....
![]() |
Similar Threads
- Clean Your Prefetch to Improve Performance (Windows tips 'n' tweaks)
- VB Script Format (Visual Basic 4 / 5 / 6)
- 2 PROBLEMS/ C++ run time libary and also i expor application error (Troubleshooting Dead Machines)
- helpppp! (Visual Basic 4 / 5 / 6)
- how do I run a "disconnected" stored procedure (MS SQL)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Winsock and looping issues unsure how to resolve
- Next Thread: In MS Flexgrid how to assign recordset to the fields ?
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading refresh remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






