'ExcelApp' is not a member of 'AddinExpress.MSO.ADXAddinModule !

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

'ExcelApp' is not a member of 'AddinExpress.MSO.ADXAddinModule !
 
Xavier N




Posts: 59
Joined: 2010-12-03
I try to access excel application in a standard module using the property ExcelApp of AddinModule but it send me the error message 'ExcelApp' is not a member of 'AddinExpress.MSO.ADXAddinModule...(It doesn't work in any project...)

Sub Procedure
...
Dim xlApp As Excel.Application = AddinModule.CurrentInstance.ExcelApp
End sub


(In the AddinModule: 'Dim xlApp As Excel.Application = Me.ExcelApp' is working).

If you have any idea or suggestions ?
Regards. Xavier
Windows 10 TH 2 - VS 2015 SP3 - Addin Express Release 8.4.4395
Posted 14 Dec, 2010 07:37:36 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Xavier,

Sorry, I don't quite understand you. Could you please send a sample add-in project to the support e-mail address (see readme.txt for details)?

FYI Please note that you use an old build of Add-in Express 2010. You can download a new one from our web site. Please don't forget to replace the adxloader.dll in the Loader folder of your project with a new one (see the Redistributables folder).
.NET, Extended MAPI, Windows Phone & RT
Posted 14 Dec, 2010 08:35:27 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Xavier,

Please try to convert an object which is returned from the CurrentInstance property to your add-in module type:

CType (ADXAddinModule.CurrentInstance, AddinModule) 


Does it help?
.NET, Extended MAPI, Windows Phone & RT
Posted 14 Dec, 2010 09:43:13 Top
Xavier N




Posts: 59
Joined: 2010-12-03
Hi Eugene,
Unfortunately the CType conversion doesn't work but i solved the problem:

Module Module1
    Sub testExcelApp() '
        Dim xlApp As Excel.Application
        'Method1: This code does not work and give the error message 'ExcelApp' is not a member of 'AddinExpress.MSO.ADXAddinModule.. 
        xlApp = AddinModule.CurrentInstance.ExcelApp()
        'Method2: This code works and adxComAddin expose ExcelApp property
        Dim adxComAddin As AddinModule = AddinModule.CurrentInstance
        xlApp = adxComAddin.ExcelApp
    End Sub
End Module


I'm coming from VBA so i don't master VB.net object oriented code really well but if anyone can give me an explaination why Method1 fail and why method2 succeed, i'll be glad of it..
Thanks Eugene
Regards. Xavier
Windows 10 TH 2 - VS 2015 SP3 - Addin Express Release 8.4.4395
Posted 14 Dec, 2010 11:12:02 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hi Xavier,

It looks like you have Option Strict Off.

AddinModule.CurrentInstance - returns AddinExpress.MSO.ADXAddinModule which doesn't contain ExcelApp; whence your first method doesn't work

Dim adxComAddin As AddinModule = AddinModule.CurrentInstance

Here, the result of AddinModule.CurrentInstance (and you already know that it is AddinExpress.MSO.ADXAddinModule) is implicitely casted to {your project}.AddinModule and this is why the second method works. If you were using Option Strict On, you would require to perform that cast explicitely, that is:

Dim adxComAddin As AddinModule = CType(AddinModule.CurrentInstance, AddinModule)
or
Dim adxComAddin As MyAddin1.AddinModule = CType(AddinModule.CurrentInstance, MyAddin1.AddinModule)

The second variant highlights that AddinModule from "CType(AddinModule.CurrentInstance..." is probably a property of the object in which your code runs, say, a property page. If so, here's the third variant:

Dim adxComAddin As MyAddin1.AddinModule = CType(Me.AddinModule.CurrentInstance, MyAddin1.AddinModule)

Two scenarios are possible:
- you continue to use Option Strict Off
- you start using Option Strict On and perform all casts explicitely

This is up to you, of course. I was a VBer in my previous life but now I prefer using C#; whenever I use VB.NET, I use explicit casts because I believe it helps me to control the things better.

God luck!

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Dec, 2010 12:00:42 Top
Xavier N




Posts: 59
Joined: 2010-12-03
Thanks for your explaination Andrei,
And for taking time to explain the subtilities of accessing AddinModule. I still need to enhance my background .net kwnowledge...
I'll follow your advice using Option Strict On
Regards. Xavier
Windows 10 TH 2 - VS 2015 SP3 - Addin Express Release 8.4.4395
Posted 15 Dec, 2010 02:15:14 Top