What version of Microsoft.Office.Interop.Excel to reference?

1,508 views
Skip to first unread message

Jiri Pik

unread,
Sep 29, 2013, 2:35:21 AM9/29/13
to exce...@googlegroups.com

Hi:

 

What version of Interop Excel shall I reference for just basic Range operations if I want to support Excel 2007, 2010 and 2013 and run on only .net 4.5.

 

 

I assume I should use the version 12? Is it safe to use version 14 (I am packing the assembly) even if the user has only Excel 2007?

 

 

Jiri Pik

website |  store | vCard | map |  email 

TwitterBlogLinkedIn

 


Confidentiality Note:  This e-mail and any attachments are confidential and may be protected by legal privilege. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you for your cooperation.

 

 

 

Govert van Drimmelen

unread,
Sep 29, 2013, 3:43:01 AM9/29/13
to exce...@googlegroups.com
Hi Jiri,

If you're using a part of the COM API that has not changed between the versions, if doesn't really matter which interop assembly you choose.
If you choose a newer interop assembly than the Excel you're running against, you might use features that are not available in the Excel, and get unexpected COM errors at runtime.

So mostly the advice would be to use the lowest version interop assembly that has the features you use.
If you set the project reference in Visual Studio to be "Embed Interop Types = true" for the interop assembly, then you need to ship it with your add-in (or pack it in the Excel-DNA .xll).

Another option is to use the version-independent NetOffice (http://netoffice.codeplex.com) assemblies. They cover the union of Excel versions, and have intellisense to indicate which Excel versions support a particular feature.
The downside is that they are not completely compatible with the Primary Interop Assemblies, so you have to change your code a little bit, and you can't embed them with the .NET 4 compiler the same way, so you have to pack and ship then in your add-in.

Regards,
Govert
Reply all
Reply to author
Forward
0 new messages