Running Excel 2010 using Excel 2013 Interop

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

Running Excel 2010 using Excel 2013 Interop
Running Excel 2010 using Excel 2013 Interop  
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.
Posted 28 Jul, 2015 15:47:34 Top
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
Posted 29 Jul, 2015 02:18:57 Top
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.
Posted 30 Jul, 2015 09:16:52 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
John,

Just yesterday I posted a set of situations in which this HRESULT occurs at https://www.add-in-express.com/forum/read.php?FID=5&TID=13263. I suppose your case relates to using an Office version the localization of which doesn't correspond to regional settings in Windows. If this is the case, you can try setting CultureInfo as shown at https://www.add-in-express.com/creating-addins-blog/2009/02/13/old-format-invalid-type-library/.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Jul, 2015 09:29:50 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
John,

Here's the project:
http://temp.add-in-express.com/support/MyAddin90ActiveWorkbook.zip


Andrei Smolin
Add-in Express Team Leader
Posted 30 Jul, 2015 09:37:37 Top