Solved

Call Java program from an Excel macro

Posted on 2004-09-06
4
4,094 Views
Last Modified: 2008-08-09
I need to write a macro to be executed from an excel spreadsheet. It needs to call a java program that will perform certain functions with the data.  

Does anyone know what i need to do to achieve this ?
0
Comment
Question by:papillon2
4 Comments
 
LVL 2

Accepted Solution

by:
Discofish earned 100 total points
ID: 11991776
Try passing names/parameters to the program via the command line. I believe it the args array in Java.  You can also turn the program into an exce http://www.duckware.com/jexepack/.  Then, just capture the output. http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20193718.html

Or if it is a JavaBean, you can try this:
http://java.sun.com/j2se/1.4.2/docs/guide/beans/axbridge/developerguide/index.html#supported


Otherwise, You'd need to create a DLL that uses the Java Native Interface and call it from VB.
0
 

Assisted Solution

by:darrylmg
darrylmg earned 100 total points
ID: 11994460
Instead of trying to write a complex interface, can you not try something a little "classy 'er".

What about this:

1, The excel macro copies the required data from the current workbook into a new workbook (I am assuming you are a competant macro writer).
2, The new workbook is then saved as a CSV (comma seperated variable) file to a specific name in the c:\temp directory.
3, The macro then calls the Java program and passes it the name of the CSV file in the c:\temp directory.
4, The Java program reads in the data from the CSV file and does it's stuff.

I am also assuming:
1, The Java program is configurable/editable by you.
2, The type of data required by the java program is text based.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now