Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add a reference to microsoft.office.interop.excel

I am running Visual Studio 2010, .NET 4.5, and Office 2010. I get a warning on some legacy code that I am trying to run that I am missing an assembly reference for Microsoft.Office.Interop.Excel==12.0.0.0 and Microsoft.Office.Interop.Access==12.0.0.0.

After searching, I was able to find this post

I installed the Primary Interop Assemblies, they show up in my control panel when I go to Add/remove programs. However, I still do not have a selectable reference to the interop assemblies from the add reference dropdown for COM or .NET addins in Visual Studio. I also do not have the interop assemblies when I navigate to C: > Windows > assembly > GAC, as was suggested in the previous post.

Searching my system for anything labeled '.Interop' does not yield the Office.Interop files. Really frustrating, because it says that the assemblies are installed.

Adding a simple reference to Microsoft.Excel and Microsoft.Access COM addins does not remove the warnings.

UPDATE: I was able to get this working. Version 12.0 of the Interop Assemblies is native to Office 2007. I was running Office 2010 which has version 14.0 of the assemblies. The assemblies are backwards compatible, but I was unable to 'see' them in the browser because I had to select my project to build on 'Any CPU' instead of just 'x86'.

like image 392
Dobbes Avatar asked Nov 26 '13 13:11

Dobbes


People also ask

Do I need to have Office installed to use Microsoft Office Interop Excel DLL?

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


2 Answers

I was able to get this working. Version 12.0 of the Interop Assemblies is native to Office 2007. I was running Office 2010 which has version 14.0 of the assemblies. The assemblies are backwards compatible, but I was unable to 'see' them in the browser because I had to select my project to build on 'Any CPU' instead of just 'x86'.

like image 105
Dobbes Avatar answered Sep 27 '22 23:09

Dobbes


You need to select 'Microsoft Office Developers Tools' when installing visual studio. See http://msdn.microsoft.com/en-us/library/54ds2za4%28v=vs.100%29.aspx

Btw, if you get 'A selected drive is no longer valid' message when changing vs setup, uninstall sp1 first.

like image 27
Ruu Avatar answered Sep 28 '22 01:09

Ruu