Word OLE : Open document [message #461259] |
Mon, 19 September 2005 18:07 |
Eclipse User |
|
|
|
Originally posted by: omry_y.inter.net.il
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);
|
|
|
Powered by
FUDForum. Page generated in 0.02617 seconds