|
Re: Embed word starting with a specified file [message #1027231 is a reply to message #1019256] |
Tue, 26 March 2013 18:27 |
Binko Binev Messages: 20 Registered: June 2012 |
Junior Member |
|
|
Hi,
I am also using this method.
clientSite = new OleControlSite(clientFrame, SWT.NONE,"Word.Document", source);
if you have debugged the OleControlSite and OleClient site classes, you can see that with the progID, the registry key for this entry is taken.
Today I had a case where a colleague/customer had Woprd.Document.8 instead of Word.Document.12 as an entry in the registry. So the app got an exception.
When you just give a file, the class reads its extension (.docx) and redirects it to the proper program which is entered for it in the registry.
public OleClientSite(Composite parent, int style, String progId, File file) {
this(parent, style);
try {
if (file == null || file.isDirectory() || !file.exists()) OLE.error(OLE.ERROR_INVALID_ARGUMENT);
appClsid = getClassID(progId);
if (appClsid == null) OLE.error(OLE.ERROR_INVALID_CLASSID);
// Are we opening this file with the preferred OLE object?
char[] fileName = (file.getAbsolutePath()+"\0").toCharArray();
GUID fileClsid = new GUID();
COM.GetClassFile(fileName, fileClsid);
OleCreate(appClsid, fileClsid, fileName, file);
} catch (SWTException e) {
dispose();
disposeCOMInterfaces();
throw e;
}
}
Here appClsid and fileClsId are equal if you have the proper registry entries.
I have another problem. I try to get a row from a table. Sometimes it works , but sometimes the Word application crashes.
This is the code:
public static Variant getRow(Variant tableVar, int rowIndex) throws OleException {
OleAutomation tableAuto = tableAuto = tableVar.getAutomation();
OleUtils.printAutomation(tableAuto);
Variant rowsVar = null;
while (rowsVar == null){
rowsVar = tableAuto.getProperty(101/*Rows*/);
}
OleAutomation rowsAuto = rowsVar.getAutomation();
Variant rowVar = rowsAuto.invoke(0/*Item*/, new Variant[]{new Variant(rowIndex)});
return rowVar;
}
I cannot understand why the application crashes. Any ideas may be?
|
|
|
Powered by
FUDForum. Page generated in 0.03508 seconds