mrbela
mrbela

Reputation: 4647

Invoking VBA Shell function but nothing happens

I've wrote my first macro and want to run an JAR-file from it:

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

If I run the macro the message box is shown but after that nothing happens (my JAR-file shows also a dialog). If I copy the command ("java -jar ....") in cmd it works fine.. All the paths are correct!

Maybe you can help me! Thanks for you help!!

Upvotes: 2

Views: 253

Answers (1)

PaulFrancis
PaulFrancis

Reputation: 5809

You need to include the path of the JAVA installation location.. Something like.

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"

Upvotes: 2

Related Questions