Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JACOB API problem

807569Sep 6 2006 — edited Sep 8 2006
I apologize if this would be better suited for another forum on this board, but I cannot find one for non-core API's.

My problem is with the JACOB (Java-COM Bridge) API. If anyone has experience with this, your input would be greatly appreciated.

Here is my code:
377        ActiveXComponent wordComponent = new ActiveXComponent (
378                "Word.Application");
379        Dispatch wordObject = wordComponent.getObject();
380        wordComponent.setProperty("Visible", new Variant (true));
381        Dispatch documents = Dispatch.get(wordObject, 
382                "Documents").toDispatch();
383        Dispatch document = Dispatch.call(documents, 
384                "add", envelopeFile).toDispatch();
385        Dispatch.call(document, "Activate");
386        Dispatch activeDocument = Dispatch.get(wordObject, 
387                "ActiveDocument").toDispatch();
On line 384 I get the error:

com.jacob.com.ComFailException: VariantChangeType failed

When I try to break the line into multiple, independent commands, I get the same error on the last line of the following:
        Variant document1 = Dispatch.call(documents, 
                "add", envelopeFile);
        Dispatch document = document1.toDispatch();
For some reason, it can't change the type from Variant to Dispatch. This all works perfectly fine for me using the Eclipse IDE, but when I export it to a JAR, sign it, and use it in an HTML page, I get this error. Any advice? Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2006
Added on Sep 6 2006
3 comments
752 views