Question : I am having trouble opening a .bat file in a VBA Excel Macro

I am using the following code to open a .bat file in a Excel VBA macro.

Sub OpenFile()

Dim RetVal
RetVal = Shell("C:\MyMonitor\Monitor\startMonitorLinux.bat", 1)
 
End Sub

The code opens the command window but I get a path not recognized error. If I go to the file directly and double click it the file opens without a problem. Please help

FYI I am still learning VB so please keep any responses in laymens terms

Thanks

Answer : I am having trouble opening a .bat file in a VBA Excel Macro

The line:
CD c:\MyMonitor\Monitor

 should be on a line by itself.

When you say "when the file is just opened directly.", how are you doing that?  Are you using explorer to navigate to where the bat file is?  What is the full path of the folder where the bat file is being launched from?

Random Solutions  
 
programming4us programming4us