I have a Word macro that needs to run using Java. So I use a VB script to
run the macro as below. It does some editing in the Word document and I use
that “test.doc” to read as an InputStream. But I have to sleep the main
thread for a while to get the document changes in the “test.doc” file (varies
the time needed to thread sleep time from document to document). As
shown in code. I am a bit confused because I wait for the process to end.
And still the document is not updated?
Can someone please help me here?
Process proc = Runtime.getRuntime().exec("cmd /c start C:\\test.vbs");
proc.waitFor();
Thread.currentThread().sleep(2000);
InputStream uploadedFileStream = new BufferedInputStream(new FileInputStream("c:\\test.doc"));
Get rid of “start”, so the created instance of Word doesn’t run in the background, and the sleep which is now unnecessary.