JACOB: ComFailException  
Author Message
vicky





PostPosted: 2007-8-16 19:35:00 Top

java-programmer, JACOB: ComFailException Hi!

I am using JACOB to automate Ms-Word. but when i am adding/opening a
document it shows an exception.
MS-Word get opened and visualized but no document has been opened
there.
Plz help me to sort out this problem.

<b>Code:</b>
ActiveXComponent dc = new ActiveXComponent ("Word.Application");
try
{
dc.setProperty("Visible", new Variant(true));

//I've tried this way also, but in vain
//Dispatch documents = Dispatch.get(dc,
"Documents").toDispatch();

//This line generates exception.
Dispatch documents =
dc.getProperty("Documents").toDispatch();
Dispatch document = Dispatch.call(documents,
"Add" ).toDispatch();

}
catch (Exception e) {
e.printStackTrace();
}

<b>Exception:</b>
com.jacob.com.ComFailException: Invoke Failed: Documents
at com.jacob.com.Dispatch.invokev(Native Method)
at
com.jacob.activeX.ActiveXComponent.getProperty(ActiveXComponent.java)
at Word.getDocuments(Word.java:17)
at WordDoc.main(WordDoc.java:20)