0

I want to run an exe file from VBA with 2 parameters. To be more specific here is the exact line that works for me in command line (Win+R), I just need it in VBA:

C:\Program Files (x86)\MacroRecorder\MacroRecorder.exe "E:\test.mcr" /a

I tried so far:

Sub open_test_file()

Call Shell("C:\Program Files(x86)\MacroRecorder\MacroRecorder.exe 'E:\test.mcr' /a")

End Sub

And this:

Public Sub StartExeWithArgument()
    Dim strProgramName As String
    Dim strArgument As String
    Dim strArgument2 As String

    strProgramName = "C:\Program Files (x86)\MacroRecorder\MacroRecorder.exe"
    strArgument = "E:\test.mcr"
    strArgument2 = " /a"

    Call Shell("""" & strProgramName & """ """ & strArgument & strArgument2 & """", vbNormalFocus)
End Sub
2
  • What do you have thus far? Commented Apr 10, 2019 at 11:46
  • I'll edit what i tried so far to the original question Commented Apr 10, 2019 at 12:33

1 Answer 1

1
Shell "C:\Program Files (x86)\MacroRecorder\MacroRecorder.exe 'E:\test.mcr' /a"

Note speech marks and quotes

Sign up to request clarification or add additional context in comments.

1 Comment

it says File not found, Call Shell("C:\Program Files(x86)\MacroRecorder\MacroRecorder.exe 'E:\test.mcr' /a")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.