我正在尝试使用VBA运行.exe程序,同时从Excel中的范围传递参数。我的代码打开cmd,但不会运行.exe程序。我已经能够使用Shell()函数成功运行.exe,但是我想做一个waitOnReturn,这样VBA就不会在.exe完成之前打开数据输出到的文件夹。有什么想法吗?
Set oShell = VBA.CreateObject("WScript.Shell")
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Master")
'Get arguments from a range in Excel worksheet
sArg = Empty
varAPI = ws.Range(rngAPI)
For i = LBound(varAPI) To UBound(varAPI)
If IsEmpty(varAPI(i, 1)) = False Then
sArg = sArg + " " + CStr(varAPI(i, 1))
End If
Next i
'Run cmd
strRoboappPath = "N:Test\_program.exe\Production.exe" + sArg
oShell.Run "cmd /C " & Chr(34) & strRoboappPath & Chr(34), 1, True
'Open folder
Dim strPath As String
strPath = "N:\Test\exports"
Call OpenFolder(strPath)