I'm using two computers, one has Office 2010 installed and the other has Office 2016. The first one is my main PC.
Let's say I started a project on the main PC. If I add a reference to any of the following:
Microsoft.Office.Interop.Word (Microsoft Word 14.0 Object Library).
Microsoft.Office.Interop.Excel (Microsoft Excel 14.0 Object Library).
Microsoft.Office.Interop.PowerPoint (Microsoft PowerPoint 14.0 Object Library).
..and then open the project on the second PC, Visual Studio will automatically select the applicable version for all of them (i.e., "Microsoft XXXX 16.0 Object Library") since "Embed Interop Type" property is set to true.
So far so good, but when I add a reference to Microsoft.Office.Core (Microsoft Office 14.0 Object Library), I can't get the same behavior, that is, when I open the project on the second PC, I find the reference with the same version (14.0) flagged with an icon indicating that the reference is missing along with warnings telling me the same thing (the reference cannot be found).
Obviously, if I remove the reference and replace it with the newer version (16.0), everything works fine except -of course- that I won't be able to open the solution on the main PC anymore.
So, my questions are:
Why doesn't it select the appropriate version for Microsoft.Office.Core like what happens with Interop.Excel, Interop.Word, etc?
Is there a solution for this so I can open the project seamlessly between the two computers?
Please note:
The main focus is not about running the application by the end user with different versions of Office (this have been asked and answered many times before). I'm more concerned about opening the solution/project on a secondary development machine with a different version of Office installed.
In case that's relevant, this is a WinForms application.
Update:
I tried copying the MSO.DLL file to a local 'lib' folder but whenever I add it as a reference, it shows "C:\Windows\assembly\GAC_MSIL\Office\14.0.0.0__71e9bce111e9429c\Office.dll" as the path of the reference. Then, no matter whether I disable/enable the Embed Interop Types property, it still doesn't compile on the secondary development machine.
Although I'm not quite sure I fully get Eugene's answer, it helped by giving me the idea of adding the PIA references in the Assemblies tab, not the COM tab and still have the Embed Interop Type property set to true. That actually seems to work but I'm not sure if not using the COM references might have any downsides. Does it?
You need to copy interop assemblies (Microsoft Word/Excel/PowerPoint/Core 14.0 Object Libraries) to a local folder in the solution. And then you can add them as references, so they will be accessible on both machines and you will be able to open the project seamlessly between the two computers.
My settings :
- Office 2010 is fully installed and running with default settings including .Net development,
- Office 2010 Primary Interop Assemblies (v14) are installed (checked with control panel programs list)
Problem : In C# or F# projects, I cannot add a reference to Microsoft.Office.Interop in the Solution Explorer window of Visual Studio 2013 Community Edition. Interop are not listed anywhere (COM, Assemblies,...)
Question : Does VS 2013 Community Edition forbid reference to Office PIA as opposed to full VS 2013 PRO ?
If not, what should I check ?
Thanks.
There is no generic reference for Office, rather, they are application specific. Under the COM tab, you can add a refernce to any of the following. The version number will vary based on the version of Office you have installed.
Microsoft Excel 14.0 Object Library
Microsoft Outlook 14.0 Object Library
Microsoft Powerpoint 14.0 Object Library
Microsoft Word 14.0 Object Library
The only real difference between the Community and Pro SKUs is that Community omits the Office dev scenarios.
My guess is that the list of dirs that are used to populate the "add reference" dialog is modified in Community, with well-known Office binary dirs removed. This is just speculation, but it would explain what you are seeing.
If you can find the location on disk of the PIAs, you should still be able to add a reference via plain "browse." AFAIK, Community doesn't explicitly block this, it just doesn't help like Pro+.
I am needing to create an Excel spreadsheet from a c# project, but I cannot add the reference to the Excel COM object.
I am using Visual Studio 2010 and office 2013. I've clicked on the References folder and selected Add Reference, and then navigated to the COM tab, setting them in alphabetical order. I looked through, but there was no reference to Microsoft.Office.Interop.Excel.
Trying to resolve the issue, I downloaded and installed the PIAs for Office 2010, but references still were not added. I'm not sure where these files would be located on the hard-drive, so I cannot just browse to them (or copy one to the project Resource folder and reference it there).
Does anyone have an idea as to why I cannot see the references?
Additional Information
I managed to get the Microsoft.Office.Interop.dll file from a coworker for Office 2013, but I was not able to reference it from my project since I am working in .NET 3.5. My manager does not want me to update the project to .NET 4.0, so it looks like I will need to use the Office 2010 PIAs I installed. Unfortunately, installing them did not add them to the list, and I haven't been able to find the dll's to add them by browsing to them.
I doubt that it will make a difference, but my dev system is Windows 8.
I'm running Visual Studio 2010 Express, and in C# I'm trying to display Excel workbook.
I'm trying to use
Microsoft.Office.Interop.Excel
I have office 2007. Why doesn't this show up when I go to add> reference and navigate to the .NET or COM tabs?
Why doesn't this show up?
How can I add this as a reference or is there a better to show a workbook to the user in Excel?
For whatever reason VS 2010 doesn't like to show it in the .NET tab of the Add Reference window, you have to manually browse for it. The path to the assembly is C:\Windows\assembly\Microsoft.Office.Interop.Excel.
Go to Add Reference
Click on the Browse tab
Browse to C:\windows\assembly
Choose Microsoft.Office.Interop.Excel
I've had decent luck using EPPlus. It was awhile ago but I chose it since at the time the interop library was specific to a single version of Office whereas epplus was compatible with any version supporting the Open Office Xml format
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?
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.
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.
After that, I was able to see 'office', this assembly contains Microsoft.Office.Core.
Hope this helps you.
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
After installing the Office PIA (primary interop assemblies), add a reference to your project -> its on the .NET tab - component name "Office"
If someone not have reference in .NET . COM (tab) or not have office installed on machine where visual was installed can do :
Download and install: Microsoft Office Developer Tools
Add references from:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Visual Studio Tools for Office\PIA\Office15
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!
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/
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.
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).
If you are not able to find PIA for Office 2013 then follow these steps:
Click on Solution Explorer in Visual Studio
Right click on your project name (not solution name)
Select 'Manage Nuget packages'
Click on Browse and search for PIA 2013, choose the shown PIA and click on Install.....
And you are done.
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()));
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
In my case when I added "Microsoft Excel Object Library" and "Microsoft Office Object Library" from Reference->COM then the reference error goes away.