28

I am having troubles adding the excel reference to my project. I have already installed Primary Interop Assemblies.

The project is detecting the Microsoft.Office.Interop.Word assembly reference correctly but the excel reference still cannot be found.

When I try to manually add the reference, I right click the project, add reference, navigate to the Microsoft.Office.Interop.Excel file and try to add it manually. Once i select the reference I then make sure the reference is checked, then hit ok. Nothing happens, it fails to actually add the reference path to the project.

Using VS2012 Ultimate.

Any suggestions on what I can do to get the project to see the excel reference?

stylex
  • 283
  • 1
  • 3
  • 5
  • 1
    Have a read of the top answer in http://stackoverflow.com/questions/15285880/how-to-reference-microsoft-office-interop-excel-dll – Paul Zahra Oct 23 '13 at 13:43
  • I have already tried this. I.e. trying to manually add the reference. It still does not recognize the .Excel reference. The .Word reference is recognized correctly. – stylex Oct 23 '13 at 13:47
  • When you manually try to add it, is it already listed in the extensions as shown in Paul's link? I know that 2012 is probably different, but when I did this in 2010 I had to use the COM reference as described here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/c9e83756-4ae2-4ed4-b154-1537f3bb3a22/cant-find-microsoftofficeinteropexceldll?forum=netfxsetup. – SausageBuscuit Oct 23 '13 at 13:52
  • It is not already listed like it is in Paul's link, I have to manually click browse and navigate to the folder that contains the .Excel reference. The directions in your link worked when adding the reference. Thanks. – stylex Oct 23 '13 at 14:06
  • No problem, added as answer. – SausageBuscuit Oct 23 '13 at 14:22
  • Run this command: Install-Package Microsoft.Office.Interop.Excel – Luca Ziegler Apr 14 '17 at 14:51

5 Answers5

46

As described in http://social.msdn.microsoft.com/Forums/vstudio/en-US/c9e83756-4ae2-4ed4-b154-1537f3bb3a22/cant-find-microsoftofficeinteropexceldll?forum=netfxsetup

  • On the Project menu, click "Add Reference."

  • On the COM tab, click Microsoft Excel Object Library, and then click Select. In Visual Studio 2012, locate Microsoft Excel 14.0 (or other version) Object Library on the COM tab.

  • Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the libraries that you selected, click “Yes”.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
SausageBuscuit
  • 1,226
  • 2
  • 20
  • 34
  • Same issue with `Microsoft.Office.Interop.Word`. I just needed to add `Microsoft Word 16.0 Object Library` from the COM tab. – Trevor Nestman Jan 16 '17 at 18:29
20

If you don't have excel installed, run this command in the nuget-packet-manager-console:

Install-Package Microsoft.Office.Interop.Excel
Luca Ziegler
  • 3,236
  • 1
  • 22
  • 39
9

I installed Microsoft office PIAs, but I had the same problem, cannot find microsoft.office.interop.excel dll, I also I installed Visual Studio 2010 Tools for the Office System 4.0 Runtime Service Pack 1 but still the problem persist.

Finally I resolve the problem with an add of Office / SharePoint development package to my Visual Studio 2017 installation:

Go to Tools > Get Tools and Features ..

And then check Office / sharepoint development and modify your installation.

  • This worked for me. Thank you so much! I was fighting this problem for days and the only answer that worked for me had 0 votes.... – Trost Jun 21 '18 at 10:48
1

I installed MS Office 13 and from then on I started getting this error in VS 2012 project. I tried adding the MS Office lib via COM control but that didnt work. Finally I had to add this library references from the "Extensions" section (not not under COM); had to select Microsoft.Office.Interop.Excel, version 15.0.0.0. That fixed the error.

Hope that helps some.

Yoda
  • 11
  • 1
0

So I had to move a project to my dev machine from a consultant.

My working machine reference pointed to Microsoft.Office.Interop My non-working machine wanted "Excel" to come from DocumentFormat.OpenXml.Spreadsheet which was also in the project.

I needed to Tools>NuGet Package Manager>Package Manager Console and type "Install-Package Microsoft.Office.Interop.Excel"

then I needed to "Add Reference" as described above.

Movin to my co-worker's machine we had to do these two steps and close and open the project to get it all to take.

DanKrhla
  • 1
  • 1