【问题标题】:Shell *.vbs from within VBA来自 VBA 的 Shell *.vbs
【发布时间】:2012-02-24 11:28:37
【问题描述】:

您好,谁能告诉我如何在 VBA 中执行我的 .vbs,因为以下代码不起作用。

RetBat4 = Shell("c:\VTS\QUEEN ANNES REVENGE\SYSTEM\VBS\UNDO_2.vbs", 1)

VBA调试说语法错误????

谢谢

【问题讨论】:

    标签: vba shell vbscript


    【解决方案1】:

    试试

    Shell("cscript ""c:\VTS\QUEEN ANNES REVENGE\SYSTEM\VBS\UNDO_2.vbs""",1)
    

    如果您的 VBS 需要完整的命令 shell 环境,请使用:

    Shell("cmd /c cscript ""c:\VTS\QUEEN ANNES REVENGE\SYSTEM\VBS\UNDO_2.vbs""",1)
    

    如果您的程序应该等到 VBS 结束,请阅读这篇文章:

    VBA Shell and Wait with Exit Code

    【讨论】:

      【解决方案2】:

      试试这个:

      Set ws=CreateObject("Wscript.shell")
      set ws.exec("ping " & ip & " -n 20")
      set ws=nothing
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-10
        • 1970-01-01
        • 2012-10-19
        相关资源
        最近更新 更多