Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Word OLE : Open document
Word OLE : Open document [message #461259] Mon, 19 September 2005 18:07
Eclipse UserFriend
Originally posted by:

I am trying to open a document with Word OLE Site.

The invokeNoReply returns error -2147352567, documents.getLastError()
returns :
"The Open method or property is not available because this document is
being edited in another application."

can anyone tell me what I am doing wrong?

File file = new File("c:\\1.doc");
// Get generic IDispatch interface
OleAutomation dispInterface = new OleAutomation(_clientSite);

// Get Application
int[] appId = dispInterface.getIDsOfNames(new String[]{"Application"});
if (appId == null) OLE.error(OLE.ERROR_APPLICATION_NOT_FOUND);
Variant pVarResult = dispInterface.getProperty(appId[0]);
if (pVarResult == null) OLE.error(OLE.ERROR_APPLICATION_NOT_FOUND);
OleAutomation application = pVarResult.getAutomation();

int[] docsId = application.getIDsOfNames(new String[]{"Documents"});
if (docsId == null) OLE.error(OLE.ERROR_APPLICATION_NOT_FOUND);
pVarResult = application.getProperty(docsId[0]);
if (pVarResult == null) OLE.error(OLE.ERROR_APPLICATION_NOT_FOUND);

OleAutomation documents = pVarResult.getAutomation();

int[] rgdispid = documents.getIDsOfNames(new String[]{"Open", "FileName"});

Variant[] rgvarg = new Variant[] { new Variant(file.getAbsolutePath())};
int nameArgs[] = new int[] { rgdispid[1] };

documents.invokeNoReply(rgdispid[0], rgvarg, nameArgs);
Previous Topic:Higher level access to OLE objects.
Next Topic:Accessibility for custom SWT widgets
Goto Forum:

Current Time: Fri May 29 23:30:30 GMT 2020

Powered by FUDForum. Page generated in 0.01559 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top