Using ExcelApp in XLLAdditionalModule

Add-in Express™ Support Service
That's what is more important than anything else

Using ExcelApp in XLLAdditionalModule
 
Henri Pellemans


Guest


Hi at ADX,

I have created an ADX XLL add-in with a lot of UDFs, so I added a XLLAdditionalModule to the project.

In the [first] XLLModule I can use ExcelApp:



Dim callerRange As Excel.Range =
                _Module.ExcelApp.Range(callerAddress)


In the XLLAdditionalModule, ExcelApp is not available, at least not without any extra code. With a little bit of trial and error I figured out the following code:


Dim callerRange As Excel.Range =
                MyXLLAddin1.XLLModule.CurrentInstance.ExcelApp.Range(callerAddress)


Now I have two questions:

1. is my code correct? It seems to work fine.

2. is a 'shortcut' possible, so I don't have to write MyXLLAddin1.XLLModule.CurrentInstance every time? Although _Module is available in the XLLAdditionalModule I can't use _Module.ExcelApp

Thanks for an answer.

Henri
Posted 03 Mar, 2012 06:58:48 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hi Henri,

1. Yes, this is correct.
2. You can use a property such as this one:


Public Shared Shadows ReadOnly Property CurrentInstance() As XLLModule
    Get
        Return CType(AddinExpress.MSO.ADXXLLModule.CurrentInstance, XLLModule)
    End Get
End Property


Then you can ise it in the additional module as follows:

XLLModule.CurrentInstance.ExcelApp


Also, you can modify the _Module property in the XLLContainer class of your XLLAdditionalModule1:

Friend Shared ReadOnly Property _Module() As MyXllAddin1.XLLModule
    Get
        Return Ctype(AddinExpress.MSO.ADXXLLModule.CurrentInstance, MyXllAddin1.XLLModule) 
    End Get
End Property



Andrei Smolin
Add-in Express Team Leader
Posted 05 Mar, 2012 00:57:48 Top
Henri Pellemans


Guest


Hi Andrei,

Thank you very much for your helpful comments.

Henri
Posted 05 Mar, 2012 08:42:28 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
You are welcome!


Andrei Smolin
Add-in Express Team Leader
Posted 05 Mar, 2012 09:12:55 Top