Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Getting the 'Application' property of a Word OleClientSite returns null
Getting the 'Application' property of a Word OleClientSite returns null [message #1064513] Wed, 19 June 2013 15:08 Go to next message
Gary Long is currently offline Gary Long
Messages: 4
Registered: June 2013
Junior Member
Hi Smile

I have an eclipse rcp application with an Editor part which contains a Word OleClientSite and a another view which listens to the editor selection event. When the editor is selected, I read the content of the Word document and display info in the view.

Here is the code of the listener in my view:

private ISelectionListener listener = new ISelectionListener() {
	
	@Override
	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
		if(part instanceof WordOleEditor) {
			WordOleEditor editor = (WordOleEditor)part;
			String activeDocument = editor.getEditorInput().getName();
			if(!backup.containsKey(activeDocument)) {
				System.out.println(activeDocument + " is new");
				viewer.setInput(getInput());
			} else {
				if(!editor.inputChanged()) {
					System.out.println(activeDocument + " is the same");
				} else {
					System.out.println(activeDocument + " has changed!");
					viewer.setInput(updateInput());
				}
			}
			viewer.expandToLevel(AbstractTreeViewer.ALL_LEVELS);
			viewer.refresh();
		}
	}
};


The Editor.inputChanged() method get the active document of the editor and read its content.

...
Variant activeDocument = null;
OleAutomation auto = new OleAutomation(oleClientSite);
int[] appId = auto.getIDsOfNames(new String[]{ "Application" });
if (appId != null) {
    Variant vApp = auto.getProperty(appId[0]);
    if (vApp != null) {
        OleAutomation application = vApp.getAutomation();
        if(application!=null){
			int[] activeId = getId(application, "ActiveDocument");
			if(activeId != null){
				activeDocument = application.getProperty(activeId[0]);
			}
			application.dispose();
		}
    }
}
auto.dispose();
...


My problem is that when I'm in the view and when I click in the editor, the first time it's ok but the second time, auto.getIDsOfNames(new String[]{ "Application" }) return null.

My OleClientSite object isinstanciated in the createPartControl() method of my EditorPart and should not be modified until the editor is closed.

Any idea?
Re: Getting the 'Application' property of a Word OleClientSite returns null [message #1064524 is a reply to message #1064513] Wed, 19 June 2013 16:14 Go to previous message
Gary Long is currently offline Gary Long
Messages: 4
Registered: June 2013
Junior Member
I found that when getting the id of the Application property returns null, the error is HResult 2147417843. I googled it and found that it seems to correspond to the OLE error 0x8001010D. I didn't find a lot of help about this error. It seems to have something to do with synchronous call to the Ole component but it doesn't really help me.

[Updated on: Wed, 19 June 2013 16:15]

Report message to a moderator

Previous Topic:Bolding selected TreeItem (answered)
Next Topic:Checkbox listener snippet?
Goto Forum:
  


Current Time: Mon Sep 22 16:28:35 GMT 2014

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

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