How do you run a .exe with parameters using vba's shell()?
This works for me (Excel 2013):
Public Sub StartExeWithArgument() Dim strProgramName As String Dim strArgument As String strProgramName = "C:\Program Files\Test\foobar.exe" strArgument = "/G" Call Shell("""" & strProgramName & """ """ & strArgument & """", vbNormalFocus)End Sub
With inspiration from here https://stackoverflow.com/a/3448682.
Here are some examples of how to use Shell in VBA.
Open stackoverflow in Chrome.
Call Shell("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & _ " -url" & " " & "www.stackoverflow.com",vbMaximizedFocus)
Open some text file.
Call Shell ("notepad C:\Users\user\Desktop\temp\TEST.txt")
Open some application.
Call Shell("C:\Temp\TestApplication.exe",vbNormalFocus)
Hope this helps!
The below code will help you to auto open the .exe file from excel...
Sub Auto_Open() Dim x As Variant Dim Path As String ' Set the Path variable equal to the path of your program's installation Path = "C:\Program Files\GameTop.com\Alien Shooter\game.exe" x = Shell(Path, vbNormalFocus)End Sub