Hi!
I'm running into trubles when my macro-code is invoked at calc-startup.
Running the samecode after calc-startup (document opened+loaded) same
Code works without anyproblems.
Is there a way to get Currentcomponent which should be a
XSpreadsheetDocument?

The macro should gain access to one sheet. So if there is another way to 
get access to the sheets ...

code:
        try
        {
                Object desktop=null;
                desktop =
x_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
                xd= (XDesktop)
UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop);
        }
        catch (Exception e1)
        {
                Debug.showMessage("Exception");
                e1.printStackTrace();
                return "error";
        }
        
        XComponent document = xd.getCurrentComponent();
        Debug.showMessage("document != null?: " + (document != null) );
        
        XModel xmodel = (XModel) UnoRuntime.queryInterface(XModel.class,
document);
                
    xSpreadsheetDocument= (XSpreadsheetDocument) UnoRuntime.queryInterface(
                                XSpreadsheetDocument.class, xmodel);
                
        XSpreadsheets xss = xSpreadsheetDocument.getSheets();
                
        try
        {
                Object o= xss.getByName( sheetname );
                xs= (XSpreadsheet)
UnoRuntime.queryInterface(XSpreadsheet.class, o);
        }
        catch (NoSuchElementException e)
        {
                Debug.showMessage( "NoSuchElement " + e.getMessage() );
                e.printStackTrace();
        }
        catch (WrappedTargetException e)
        {
                Debug.showMessage( "WrappedTarget: " + e.getMessage() );
                e.printStackTrace();
        }


Running this code at startup I geht the message document != null?: false
But if I invoke the macro later its true

Thanks for any Help,
  Martin



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to