Shell ( ) Function Returning 0

  • Thread starter Thread starter Jen
  • Start date Start date
J

Jen

Hi All,

I'm having a problem with the Shell Function. I'm passing
in the .exe file along with a configuration file that the
application uses....works fine the first time. retVal
returns a non zero. Second time around, retVal = 0. I
can't figure out why it's returning a 0. What's even more
strange is that the .exe opens up, yet the retVal = 0.

Sub activateWedge()
Dim x, retVal
Dim cmdLine As String

cmdLine = "C:\WINWEDGE\WINWEDGE.EXE
C:\WINWEDGE\CONFIG_1.SW1"

retVal = Shell(cmdLine)
x = Now + TimeValue("00:00:03")
Do While Now < x
DoEvents
Loop

If retVal = 0 Then
MsgBox "Cannot find winwedge.exe"
Exit Function
Else
AppActivate "Diameter Gauge Application"
End If

chan = DDEInitiate("WinWedge", "Com1")
DDEExecute chan, "[AppExit]" ' specific command that the
' .exe file recognizes
' this code works fine

AppActivate "Diameter Gauge Application"
' I'm only exiting the app for test purposes - until I get
' it so that retVal <> 0

End Sub


TIA for any help on this one.

Regards,
Jen
 
Back
Top