调用VBA Shell函数但没有任何反应

时间:2014-12-17 09:13:39

标签: vba shell excel-vba excel

我已经写了第一个宏,想要从中运行一个JAR文件:

Sub verarbeitungTest()

    Dim pfad As String
    pfad = "C:\temp\StapelverarbeitungOutput.xml"

    Dim fileExists As Boolean
    fileExists = (Dir(pfad) <> "")

    If fileExists Then
      Kill pfad
    End If

    Dim test As XlXmlExportResult

    test = ActiveWorkbook.XmlMaps("edts_Zuordnung").Export(URL:=pfad)

    If test = xlXmlExportValidationFailed Then

        MsgBox ("Validation error!")
        Kill pfad

    Else

        MsgBox ("Good!")
        Dim procID As Integer
        procID = Shell("java -jar H:\Sources\workspace_eclipse_luna\JImp\target\JImp-0.0.1-SNAPSHOT-jar-with-dependencies.jar H:\Sources\workspace_eclipse_luna\JImp\config\log4j_config.xml H:\Sources\workspace_eclipse_luna\JImp\config\JImpConfig.xml C:\temp\StapelverarbeitungOutput.xml")

    End If

End Sub

如果我运行宏,则会显示消息框,但之后没有任何反应(我的JAR文件也显示了一个对话框)。如果我在cmd中复制命令(“java -jar ....”)它工作正常..所有路径都是正确的!

也许你可以帮助我! 谢谢你的帮助!!

1 个答案:

答案 0 :(得分:1)

您需要包含JAVA安装位置的路径..类似于。

Shell """C:\Program Files\Java\jre7\bin\java"" -jar H:\Sources\workspace_eclipse_luna\JImp\target\JImp-0.0.1-SNAPSHOT-jar-with-dependencies.jar"
相关问题