97

Using the example provided in codeproject I am struggling to work out where I can find the reference to the library Microsoft.Office.Core.

I am getting the error "The referenced component 'Microsoft.Office.Core' could not be found."

I only have office 2007 enterprise edition and outlook 2003 installed on this system. Could this be the cause of this? Otherwise which specific dll am I supposed to be referencing?

Adil
  • 139,325
  • 23
  • 196
  • 197
Maxim Gershkovich
  • 42,124
  • 39
  • 134
  • 227

13 Answers13

162

You can add reference of Microsoft.Office.Core from COM components tab in the add reference window by adding reference of Microsoft Office 12.0 Object Library. The screen shot will shows what component you need.

enter image description here

Adil
  • 139,325
  • 23
  • 196
  • 197
  • .NET->Office (if PIA installed). See Spike's answer below. – samis Dec 30 '14 at 21:34
  • 4
    I used "Microsoft Office **14.0** Object Library" (12.0 didn't exist) and it worked as well. Also, I had to delete the reference to "Microsoft.Office.Core" first. – marsze Mar 09 '17 at 09:37
  • Jazakallah Adil bhai. Worked for me. – shaikhspear Apr 01 '17 at 09:47
  • 2
    I am using Visual Studio 2017 but I cannot see the the "Microsoft Office XX.X Object Library" in the COM tab. Do I need to install "Microsoft Office"? – Casper Jul 27 '17 at 01:26
  • @Kin Did you find out what to do? I'm also using VS 2017 and I don't see a reference to the office's libraries. Did you have to install Microsoft Office? – Luis Palacios Sep 27 '17 at 16:21
  • Thank you very much – destinydz Dec 28 '17 at 10:12
  • @Kin Once you add the reference from the COM tab, reference it in the class file with `using Outlook = Microsoft.Office.Interop.Outlook;` – killa-byte Aug 29 '18 at 20:33
  • I used "Microsoft Office 16.0 Object Library" (12.0 didn't exist) and it worked as well. Also, I deleted the reference to "Microsoft.Office.Core" first. This is when I have Office App (Office 365) installed version 18.2008.12711.0 and also Visual Studio 2019 installed along with Visual Studio 2005 – Ozair Kafray Jan 26 '21 at 14:37
24

None of the above answer helped me, i was using Visual Studio 2017. What I did is, installed Office/SharePoint Development using Visual Studio Installer.

enter image description here

After that, I was able to see 'office', this assembly contains Microsoft.Office.Core.

enter image description here

Hope this helps you.

Abhimanyu
  • 1,895
  • 1
  • 24
  • 39
18

You need to download and install the PIA (primary interop assemblies) for the version of Office you are using. Once installed you can then add a reference to your project and they will be available from the add reference dialog. Here are the links to download them...

Office 2010 PIA

Office 2007 PIA

Office 2003 PIA

Phil Wright
  • 21,516
  • 12
  • 77
  • 129
5

If someone not have reference in .NET . COM (tab) or not have office installed on machine where visual was installed can do :

  1. Download and install: Microsoft Office Developer Tools
  2. Add references from:

    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Visual Studio Tools for Office\PIA\Office15
    
shA.t
  • 15,232
  • 5
  • 47
  • 95
4

After installing the Office PIA (primary interop assemblies), add a reference to your project -> its on the .NET tab - component name "Office"

Spike
  • 59
  • 1
3

Now there is a nuget package for that.

https://www.nuget.org/packages/NetOffice.Core.Net40/

First I didn't find office in COM, so tried this nuget and it worked!

Mr. Ott
  • 191
  • 1
  • 2
  • 12
  • 1
    Adding to answer: If you install an Office Interop lib through the NuGet package manager console (say PowerPoint or Excel), it looks to install this, too... the same does not seem to be true if you use the Visual Studio NuGet GUI – Thumper Jul 11 '17 at 21:45
3

You can use this NuGet package which includes the interop assemblies in addition to the office assembly.

https://www.nuget.org/packages/Bundle.Microsoft.Office.Interop/

Matt Scully
  • 373
  • 2
  • 9
2

In case you are using Visual Studio 2012, for this to work and in order to make reference to Microsoft Office Core, you have to make the reference through Visual Studio by clicking on the top menu's Project, Add Reference, Extensions button and checking office which is now (14.0).

Celeo
  • 5,017
  • 8
  • 35
  • 39
Humbert
  • 41
  • 2
2

Have you actually gone to your references and added a .NET reference to the 'Microsoft.Office.Core' library? If you downloaded the example application, the answer would be yes. If that is the case, follow the advice in the article:

If your system does not have Microsoft Office Outlook 2003 you may have to change the References used by the "OutlookConnector" project. That is to say, if you received a build error described as "The type of namespace name 'Outlook' could not be found", you probably don't have Office 2003. Simply expand the project references, remove the afflicted items, and add the COM Library appropriate for your system. If someone has a dynamic way to handle this, I'd be curious to see you've done.

That should solve your problem. If not, let us know.

IAmTimCorey
  • 15,439
  • 5
  • 34
  • 70
1

If you are not able to find PIA for Office 2013 then follow these steps:

  1. Click on Solution Explorer in Visual Studio
  2. Right click on your project name (not solution name)
  3. Select 'Manage Nuget packages'
  4. Click on Browse and search for PIA 2013, choose the shown PIA and click on Install.....

And you are done.

Deepesh
  • 495
  • 4
  • 11
0

I faced the same problem when i tried to open my old c# project into visual studio 2017 version. This problem arises typically when you try to open a project that you made with previous version of VS and open it with latest version. what i did is,i opened my project and delete the reference from my project,then added Microsoft outlook 12.0 object library and Microsoft office 12.0 object libraryMicrosoft outlook 12.0 object library

0

In my case when I added "Microsoft Excel Object Library" and "Microsoft Office Object Library" from Reference->COM then the reference error goes away.

-1

I have the same trouble. I went to Add references, COM tab, an select Microsoft Office 15.0 Objetct Library. Ok, and my problem ends.

part of my code is:

EXCEL.Range rango;
            rango = (EXCEL.Range)HojadetrabajoExcel.get_Range("AE13", "AK23");
            rango.Select();
      //      EXCEL.Pictures Lafoto = (EXCEL.Pictures).HojadetrabajoExcel.Pictures(System.Reflection.Missing.Value);
            EXCEL.Pictures Lafoto = HojadetrabajoExcel.Pictures(System.Reflection.Missing.Value);

            HojadetrabajoExcel.Shapes.AddPicture(@"D:\GENETICA HUMANA\Reportes\imagenes\" + Variables.nombreimagen,
                Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue,
                float.Parse(rango.Left.ToString()),float.Parse(rango.Top.ToString()), float.Parse(rango.Width.ToString()),
                float.Parse(rango.Height.ToString()));