VBA在参数cmd.exe中使用多个引号执行函数

问题描述 投票:0回答:1

这是一个语法错误。如何正确运行ShellWait函数?我关心使用双引号。布尔参数应该能够更改为false。我不是每天都使用VBA,所以如果可以,我会问一个例子。

Sub ShellWait(fName As String, Optional showWindow As Boolean = True)
    Dim wsh As Object
    Set wsh = VBA.CreateObject("WScript.Shell")
    wsh.Run fName, -showWindow, True
End Sub

Private Sub Document_close()
    ShellWait "cmd /c echo ^<meta http-equiv="x-ua-compatible" content="IE=10"^> && echo '"hello"' "
    ' ^the above code does not work
    ShellWait "cmd /c echo '"hello"' "
    ' ^the above code does not work, syntax error
    ShellWait (cmd /c echo '"hello"')
    ' ^the above code does not work, syntax error
End Sub
vba function
1个回答
0
投票

您可以使用以下内容

ShellWait "cmd /K echo ^<meta http-equiv=""x-ua-compatible"" content=""IE=10""^> && echo '""hello""' "
© www.soinside.com 2019 - 2024. All rights reserved.