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:
use Runtime.exec to launch the program. You can do this directly as part of your program.
use Ant, which has an exec task, or maven which has an exec plugin. This is most useful when invoking the script as part of a build or some other batch process.
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.