Solved

Running a java app in VBA code

Posted on 2011-02-25
310 Views
I have a java app that runs from a command line. I need to be able to call it in VBA.

Scenario:
I have code that populates a table and then exports that table to a CSV file. I then go manually run the java app on a command line using the new csv file as one of the runline parameters i.e. 'CalculateValues myNewInputFile.csv myNewOutputFile.csv' the app creates an output file call myNewOutputFile.csv.

I would like to automate this so that I dont have to go out and manually run the java app each time.
0
Question by:Bangerter
• 2

LVL 75

Accepted Solution

käµfm³d   👽 earned 500 total points
ID: 34980739
Have you tried using the Shell() function:
Shell """C:\path\to\java.jar"" ""C:\path\to\file1.csv"" ""C:\path\to\output.csv"""

0

LVL 2

Author Closing Comment

ID: 34981879
Thanks. with a little tweaking i was able to get it to work. Here is the shell command I ended up with:

Shell ("D:\Data\myJavaTool.bat myInput.csv myOutput.csv")
0

LVL 75

Expert Comment

ID: 34981981
That will work find if none of the paths have spaces. You would need to quote each path that has spaces (as demonstrated in my post).
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.