Howto open existing document

R

Roland Leisch

Hello!

Im using a Java-COM bridge to access Word from Java. I have managed to
create a OLEContainer containing a new word-document. My problem now is,
that if I try to open an existing Word document using Documents.open the
new document is opend in a new window and not in the ole container - can
anyone help?

Thanks in advance!


_container = new OleContainer();
_container.createObject(DOCUMENT_PROGID);

_DocumentImpl document = new _DocumentImpl(_container.getOleObject());
Documents documents = document.getApplication().getDocuments();
documents.open2002(new
Variant("c:\\test.doc"),Variant.createUnspecifiedParameter(), new
Variant(true),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),
Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter());

documents.item(new Variant("test.doc")).activate();
 
R

Roland Leisch

Roland said:
Hello!

Im using a Java-COM bridge to access Word from Java. I have managed to
create a OLEContainer containing a new word-document. My problem now is,
that if I try to open an existing Word document using Documents.open the
new document is opend in a new window and not in the ole container - can
anyone help?

Thanks in advance!


_container = new OleContainer();
_container.createObject(DOCUMENT_PROGID);

_DocumentImpl document = new _DocumentImpl(_container.getOleObject());
Documents documents = document.getApplication().getDocuments();
documents.open2002(new
Variant("c:\\test.doc"),Variant.createUnspecifiedParameter(), new
Variant(true),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),
Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter(),Variant.createUnspecifiedParameter());


documents.item(new Variant("test.doc")).activate();

Solved the problem:

_container = new OleContainer();
File f = new File("c:\\test.doc");
_container.createObject(f);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top