Hello,
With VBA I load a batch script. Then I run a 2nd procedure in VBA. The 2nd procedure should only run if the batch script is closed.
Sub BatchFile()
Dim RetVal
RetVal = Shell("C:\Batch.bat", vbHide)
End Sub
I found the following somewhere on Google. I do not know if it has to do with what I want.
Sub OpenFileAndWait()
Dim sApp As String
'// Define the Application FullPath here
sApp = "C:\A\Batch.bat"
'sApp = "C:\windows\system32\calc.exe"
'// Lets DoIt
ShellAndWait sApp
'// Tell me if Successful
MsgBox "Finished running task!"
End Sub
Sub IsTaskRunning()
' If file does not exist, GoTo error trap.
On Error GoTo itrErrTrap
' Run sample batch file in MS-DOS window.
Shell "c:\test.bat"
Do
' Note: When specifying the Application name
' with the Exists(Name) argument, omit the
' Application extension.
test = Tasks.Exists("test")
Loop Until test = 0
MsgBox "The application has quit."
itrErrTrap: ' Note: This line must be left aligned.
If Err > 0 then MsgBox Err.Description
End Sub
I get here a message: Object required
If anyone can help me I appreciate it.
Best regards,
grid
Bookmarks