Solved

# Running a java app in VBA code

Posted on 2011-02-25
Medium Priority
328 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 2000 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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
###### Suggested Courses
Course of the Month5 days, 7 hours left to enroll