Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Microsoft.Office.Interop.* version 12 and 14?

I have installed Visual Studio 2010 and Office 2007. When I go to "Add Reference" and search for "Office Interop" I can see that each of the references appear twice with versions 12 and 14.

I initially tried version 14 of Microsoft.Office.Interop.Word and did a quick test. Initialise the Application, open a Document, close the Document, quit the Application, and release the COM object. My test was a simple WinForms program in C# 4.0.

WINWORD.EXE crashed while closing the document.

I switched the reference to version 12, and left my code exactly as it was and tried it again. Everything worked fine.

I have since written the rest of my code using version 12 and haven't had any problems.

So now I'm curious: There are some small differences between the publicly exposed members in Microsoft.Office.Interop.* in versions 12 and 14, but largely there is a lot of overlap.

What is the actual difference? Why did my simple test fail even though I have a relatively new version of Office? and is there a rule-of-thumb as to which version should the developer choose when starting an interop project?

like image 490
Ozzah Avatar asked Oct 13 '11 03:10

Ozzah


People also ask

What is Microsoft Office Interop?

Microsoft Office Interop (Excel Automation) is an option when creating/reading Excel files (XLS, XLSX, CSV) from C# or VB.NET application, but it has many drawbacks.

What is Microsoft 2010 primary interop assemblies used for?

The PIA enables managed code to interact with a Microsoft Office application's COM-based object model.

Does Microsoft Office Interop Excel require Excel to be installed?

Yes, you are right. You need Excel to be installed to use the Excel Manipulation feature with Microsoft. Office.


1 Answers

Version 12 is interop for Office 2007, while 14 is for Office 2010. AFAIK, unless you really need some new features of 14th version, you can use a lower version of interop library and it will work fine for all newer versions of Office.

like image 63
Petr Abdulin Avatar answered Oct 01 '22 11:10

Petr Abdulin