On Aug 22, 3:36 am, Daniel Pitts <googlegrou...@coloraura.com> wrote:
On Aug 20, 11:47 pm, "lion...@gmail.com" <lion...@gmail.com> wrote:
Hi all,
I have a vbscript that I would like to execute from java. It takes 4
arguments, and example usage follows:
"C:\cvs_checkout\tool\Projects\UserInterface\utils
\ReplaceWorksheets.vbs" "C:\Documents and Settings\vandenbergl\Desktop
\sheet.xml" "Sheet 1,Sheet 2" "C:\Documents and Settings\vandenbergl
\Desktop\Test\another sheet.xml" "sheet 1,sheet 2"
Here is the code that I'm using at the moment:
String[] command = {"cmd.exe", argument};
try {
Process mergeProcess = Runtime.getRuntime().exec(command);} catch (IOException ioe) {
ioe.printStackTrace();
}
Where argument is the expression I gave above.
If I executre the expression I gave at a prompt it does exactly what I
want, but the java code I gave doesn't do anything at all. It doesn't
throw any exceptions but it appears the script hasn't even run!
Any ideas about how I can get the script to run?
Why run a VB script from Java? You'll never make a portable
application that way.
State the obvious :).
Why not rewrite the VB script into Java, or alternatively, write it in
javascript and use the scripting api in Java 6.
I need to manipulate excel spreadsheets. Can I do that with scripting
API in Java 6? Aside from that, the minimum requirements for the user
is Java 5. I didn't take this decision lightly. I was hacking out the
excel xml files by hand at one stage but it just proved to be to much
work and too fragile for when M$ changes their xml format (you know it
will happen :)).
I'm able to wrap the whole problem up in verybadscript in about 10
lines of code.
Lionel.