I have a VB macro created. I want to pass the macro a string and a file location. How would I call this in java code. Is there a library for this?
You can run vbscript using the "cscript.exe" that ships with windows.
Depending upon your scenario, you can launch this from Java in a variety of ways:
EDIT: If your script has a GUI, then use "wscript.exe".
I'm assuming you mean vbscript, but if you reall mean a macro, such as a Word macro, then you will need to do something like this:
"C:\Program Files\Microsoft Office\Office12\Winword.exe"
"C:\MyPath\MyDoc.doc" /m"Macro1"
Alternatively, you can create a small vbscript that instantiates the Word Application and uses the run() method to invoke a macro. You execute that script using cscript.exe/wscript.exe.
There is the "JACOB - Java COM Bridge" on SourceForge. The project has a second, more dated homepage.
And then there is a commercial (D)COM/ActiveX automation library called J-Integra, which also looks like it could do such a thing.
Disclaimer: Those are just links I've pulled out of Google, I have no practical experience with these libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With