Hi everyone,
I'm having an issue in some cases while trying to open a Word document. What happens is that if Word displays a messagebox, my application simply hangs. I'm there for looking for a way to start Word and tell Word not to display any sort of message. I found this C# code which seems to do what I want to do...
public Microsoft.Office.Interop.Word.Application wa = null;
wa.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
Any ideas on how I can do this in Java using ComfyJ?
Here is my Java code...
try
{
OleFunctions.oleInitialize();
} catch (Exception e) {
log.error("Unable to Initialize JniWrapper: " + e.getMessage());
throw new Exception("Unable to Initialize JniWrapper: " + e.getMessage());
}
_Application app = Application.create(ClsCtx.LOCAL_SERVER);
app.setVisible(new VariantBool(false));
_Document doc = null;
try
{
doc = app.getDocuments().add(new Variant(WORKING_FOLDER + fileName + ".doc"),
Variant.createUnspecifiedParameter(),
Variant.createUnspecifiedParameter(),
Variant.createUnspecifiedParameter());
} catch (Exception e) {
if (doc != null) {
// Close the Word document.
doc.close(new Variant(WdSaveOptions.wdDoNotSaveChanges), Variant.createUnspecifiedParameter(), Variant.createUnspecifiedParameter());
doc = null;
}
if (app != null) {
// Close Microsoft Word.
app.quit(Variant.createUnspecifiedParameter(), Variant.createUnspecifiedParameter(), Variant.createUnspecifiedParameter());
app = null;
}
log.error("Unable to open DOC... " + WORKING_FOLDER + fileName + ".doc - (" + e.getMessage() + ")");
throw new Exception("Unable to open DOC... " + WORKING_FOLDER + fileName + ".doc - (" + e.getMessage() + ")", e);
}
Thanks!