This Question is Answered

2 "helpful" answers available (2 pts)
6 Replies Last post: Jan 19, 2010 1:52 AM by Krzysztof  
Krzysztof   4 posts since
Jan 14, 2010
Currently Being Moderated

Jan 14, 2010 1:15 PM

GUI Modifications in Excel from ComFyJ

Hello,

I'am trying to modify the ExcelIntegrationSample from ComFYJ so that i can hide/disable toolbars.

Unfortunately i'm reciving exceptions and the code does not work.

For example:

 

_Workbook workbook = new _WorkbookImpl(_container.getOleObject());

Window window = workbook.getApplication().getActiveWindow();
if(window.getDisplayFormulas().getBooleanValue()){
     window.setDisplayFormulas(VariantBool.FALSE);
}

 

Or

int size = (int) cb.getCount().getValue();
for (int i = 1; i < size; i++) {
     CommandBar c = cb.getItem(new Variant(i));  
     c.setVisible(VariantBool.FALSE);
}

 

 

I Would greatly appriciate an working example of how to modify excel user interface from ComFYJ.

Also wonder why the simple invocations like following throw exceptions?

Does it need to be called in special thread, maybe it has to do with vm or office version ?

 

window.setDisplayFormulas(VariantBool.FALSE);
window.setDisplayGridlines(VariantBool.FALSE);


Thanks,

Krzysztof

Serge Piletsky TeamDev Ltd. 996 posts since
Apr 24, 2006
Currently Being Moderated
1. Jan 14, 2010 3:13 PM in response to: Krzysztof
Re: GUI Modifications in Excel from ComFyJ

Hi Krzysztof,

 

What kind of exception are you actually receiving? If it's a COM marshalling exception then this code should be invoked in the OleMessageLoop of the _container object, for example:

_container.getOleMessageLoop().doInvokeAndWait(new Runnable() {
    public void run() {
        // your code
    }
}

 

Also, please take a look at our JExcel product which provides the convenient Java API for Excel and you should not care about marshalling.

 

-Serge

Serge Piletsky TeamDev Ltd. 996 posts since
Apr 24, 2006
Currently Being Moderated
3. Jan 14, 2010 4:13 PM in response to: Krzysztof
Re: GUI Modifications in Excel from ComFyJ

Hi Krzysztof,

 

We could not reproduce such DISP_E_EXCEPTION exception in our test environment. Could you please send us a complete test case? Also, please clarify how did you generate the stubs for Excel, was the "Prefer Automation" option enabled in Codegen application?

 

Also, it is possible to get the cause of the AutomationException, for example:

try {
  // function call
} catch (AutomationException e) {
  ExcepInfo info = e.getExceptionInformation();
  String description = getBstrDescription();
  System.err.println(description);
}

This code should print out the detailed exception information, so we can understand what COM component complains about.

 

Thanks.

 

-Serge

Serge Piletsky TeamDev Ltd. 996 posts since
Apr 24, 2006
Currently Being Moderated
5. Jan 16, 2010 9:32 PM in response to: Krzysztof
Re: GUI Modifications in Excel from ComFyJ

Hi Krzysztof,

 

Thanks for the update. We managed to run your updated example without any exception. You have mentioned that in your case the version of MS Office is not registered. That probably could be the explanation why that exception occurs.

 

-Serge

More Like This

  • Retrieving data ...