Dobbes
Dobbes

Reputation: 134

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'.

Upvotes: 6

Views: 7327

Answers (3)

browsermator
browsermator

Reputation: 1354

I had this happen when going back to a very old version of Office (went from 360 to 2000)... I had to download the PIA redistributables from here: https://www.microsoft.com/en-us/download/details.aspx?id=3508

Then I had extract the .msi file that the "PIARedist.exe" file created. I used 7-zip for that. (Running the .msi installer didn't work for some reason. Not quite sure why...) I removed the reference to "Microsoft.Office.Interop.Excel", and then I added/browsed for "EXCELPIA.DLL" which I had extracted from the .msi file. This seemed to resolve the issue I had.

Upvotes: 1

Ruu
Ruu

Reputation: 63

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.

Upvotes: 2

Dobbes
Dobbes

Reputation: 134

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'.

Upvotes: 4

Related Questions