John Putman
Posts: 25
Joined: 2012-12-02
|
In the past, I have used the 'use earliest supported version' of the interops when developing my Excel Addins. currently, I have an addin that supports only 2010 and 2013. We have some code that we'd like to start working on that is 2013-specific (PowerPivot stuff). I'd like to use only one version of interops and would like to see if I can avoid late-binding (which may just end up being impossible).
I have looked through the https://www.add-in-express.com/creating-addins-blog/2010/03/16/interop-assemblies-late-binding/ article. It sounds like I should be able to use the 2013 interops and simplynot allow any calls that would fail for a 2010 user. Am I reading this correct?
So far I have tried using the 2013 interop to run my addin and it works in 2013 (of course) but when I try to open 2010 using them, I am running into errors accessing common methods/properties (like getting the ActiveWorkbook from the Application object).
I may be doing something wrong that I need to look into - my main question is whether you believe that I should be able to use 2013 interops against Excel 2010 as long as I do not call methods that are 2013-specific. |
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Hello John,
John Putman writes:
It sounds like I should be able to use the 2013 interops and simplynot allow any calls that would fail for a 2010 user. Am I reading this correct?
Correct. That is, this isn't so in the general case; it is correct in 99,99%. The incompatibilities relate to some properties/methods/parameters dropped in some Excel versions.
John Putman writes:
So far I have tried using the 2013 interop to run my addin and it works in 2013 (of course) but when I try to open 2010 using them, I am running into errors accessing common methods/properties (like getting the ActiveWorkbook from the Application object).
I've just created an Excel 2013 add-in that loads in Excel 2010 (set minOfficeVersionSupported="14" in adxloader.dll.manifest). In the Click event of a Ribbon button I call this code:
private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed) {
Excel.Workbook wbk = ExcelApp.ActiveWorkbook;
bool result = (wbk != null);
MessageBox.Show(result.ToString());
}
It works correctly for me; no exception occurs.
Can you send me a project reproducing this to the support email address? You find the address in {Add-in Express installation folder}\readme.txt. Please make sure your email contains a link to this topic.
Andrei Smolin
Add-in Express Team Leader |
|
John Putman
Posts: 25
Joined: 2012-12-02
|
Thanks Andrei - I tried doing the same thing and when I try to access the ActiveWorkbook like above, an error is thrown. I have sent you (at the support email) a test project and the text of the error. I am wondering if it might be something directly on my system causing the problem.
Perhaps you could send me the test project you made and I'll try it out - if that one fails, it will point to being my issue. |
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
|