Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4168
  • Last Modified:

Call Java program from an Excel macro

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
papillon2
Asked:
papillon2
2 Solutions
 
DiscofishCommented:
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
 
darrylmgCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now