How do I pass multiple variables from an Excel file to a batch file

后端 未结 2 1609
陌清茗
陌清茗 2021-01-29 01:46

I am currently able to pass one argument from my Excel file to my batch file using the following:

 filepath = \"C:\\Users\\agaron\\Desktop\\batchmaster\\batchfi         


        
2条回答
  •  无人共我
    2021-01-29 02:49

    Windows batch files get different parameters delimited by spaces. So if your batch file batchfiletest.bat is like:

    echo off
    echo %1
    echo %2
    echo %3
    pause
    

    then the following VBA should run properly:

    Sub testBatch()
     sMonth = Format(Now, "mmmm")
     sDay = Format(Now, "dd")
     sYear = Format(Now, "yyyy")
     filepath = "C:\Users\axel\batchfiletest.bat " & sMonth & " " & sDay & " " & sYear
     Shell filepath, vbNormalFocus
    End Sub
    

提交回复
热议问题