Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an excel VSTO add-in be compatible with excel 2007 and 2010?

Tags:

excel

vsto

Is it possible to develop an excel add-in using VSTO that can be deployed to both excel 2007 and 2010?

Any links to a detailed resource on this topic would also be appreciated - I can't seem to find anything on google that specifically addresses this question.

I am developing a C# excel add-in using Visual Studio 2010.

like image 774
Dan Ling Avatar asked Feb 26 '23 22:02

Dan Ling


1 Answers

I already answered this for Word, but it also applies to Excel:

If you want to deploy to Office 2010 AND 2007, you have to add references to the v12.0 assemblies (Microsoft.Office.Interop.Excel and Office).

Now there is still the problem that your addin will require the 2007 PIA, but they won't install if you only have Office 2010 on the target machine (because they have Office 2007 as a prerequisite). To solve this you have to set Embed Interop Assemblies = true for those two dlls (in the reference properties) and use dynamic for the types you can't directly reference anymore.

This causes some "weirdness" with Intellisense not finding methods etc., but it should not be a big problem -at least now PIA are not required anymore and your addin will deploy on both 2007 and 2010 (you'll have to take care of the installer as well, but that is a whole other story).

It's a bit of a mess, but if you are working with VSTO I suppose you are used to this kind of stuff :-)

like image 183
Francesco De Vittori Avatar answered Apr 09 '23 10:04

Francesco De Vittori