I am trying run a batch file placed at a particular path. The file requires user inputs for which I want the parameters to be passed from Excel cells. This execution of the batch file within Excel should happen by usage of click command button.
I am new to VBA. I tried the following code, but on clicking the button nothing is happening.
Private Sub CommandButton2_Click()
sid = Excel.Worksheets("Sheet1").Range("I8").Value
user = Excel.Worksheets("Sheet1").Range("I9").Value
Password = Excel.Worksheets("Sheet1").Range("I10").Value
msg = "hi"
Shell ("CMD.EXE /c C:\Users\shashank.b03\Desktop\test_CMD.bat" & sid &" "& user &" "& password &" ")
End Sub
sidanduser? Would a working file be"CMD.EXE /c C:\Users\shashank.b03\Desktop\test_CMD.bat"SID USER PASSWORD? (Do you perhaps need a delimiter in there?) For a test, addDim myCMD as StringthenmyCMD = "CMD.EXE /c C:\Users\shashank.b03\Desktop\test_CMD.bat" & sid &" "& user &" "& password &" "and thendebug.print myCMDand see what the command that would be called actually looks like, and see if that's accurate.echo off echo enter user set /p user= echo %user% echo enter password set /p password= echo %password% echo enter sid set /p sid= echo %sid% echo %user% %password% %sid% >> C:\users\shashank.b03\desktop\test.txt