AcousticalConsultant
Technical User
Hi,
I need my macro to shell to DOS, run a program (which just translates a binary file to text), close the shell window and then continue running my code.
Since the "Shell" command runs asynchronously, I had to put a "wait" command in there for now, and on top of it, the window stays open after it's finished. Leaving it up to the user to close the window once the macro has finished.
Here's my code:
Private Sub cmdOK_Click()
If (txtInputFilename.Text <> "" Then
myval = Shell("c:\program.exe " & _
txtInputFilename.Text & " c:\temp.asc", 6)
End
Else
MsgBox "Invalid Filename!", vbCritical
Trans.Show
Exit Sub
End If
.
.
.
End Sub
Application.Wait Now + TimeValue("00:00:03"
So I need my code to wait until the shell window returns "finished", and then to close that window and continue on with my code.
Also, as you can see, if the user enters a null string, it will return the msgbox "invalid filename!", but how do I modify it so that if the user enters any file name that doesn't exist, the error will pop up?
I need my macro to shell to DOS, run a program (which just translates a binary file to text), close the shell window and then continue running my code.
Since the "Shell" command runs asynchronously, I had to put a "wait" command in there for now, and on top of it, the window stays open after it's finished. Leaving it up to the user to close the window once the macro has finished.
Here's my code:
Private Sub cmdOK_Click()
If (txtInputFilename.Text <> "" Then
myval = Shell("c:\program.exe " & _
txtInputFilename.Text & " c:\temp.asc", 6)
End
Else
MsgBox "Invalid Filename!", vbCritical
Trans.Show
Exit Sub
End If
.
.
.
End Sub
Application.Wait Now + TimeValue("00:00:03"
So I need my code to wait until the shell window returns "finished", and then to close that window and continue on with my code.
Also, as you can see, if the user enters a null string, it will return the msgbox "invalid filename!", but how do I modify it so that if the user enters any file name that doesn't exist, the error will pop up?