I have not done any programming for quite some time, so apologies if this is simple. I have had a look on several forums but haven't found quite what I am looking for.
I have Microsoft Office 365 ProPlus with Excel Version 1902. The Office version was pushed centrally form IT; a click to run type deployment so I didn't have options to ensure PIAs were enabled.
I am using C# in Visual Studio Community 2017.
I am wanting to include the Microsoft.Office.Interop.Excel reference to allow me to do certain operations in Excel from within my application.
When I attempt to Add the reference to my project, under assemblies there are non of the PIAs available.
However when I look under the COM options there is the "Microsoft Excel 16.0 Object Library" available.
How do I install or enable the PIAs so that I can use these with Office 365?
I am developing my first Outlook Add-In in C#. In Visual Studio I have the options to develop an "Outlook 2010 Add-in" or "Outlook 2013 Add-in" or probably an "Outlook 2016 Add-in".
This Add-In should work on one PC which runs currently Outlook 2010 but which I could upgrade to a newer version.
If I start to develop an "Outlook 2010 Add-in" will this also work in Outlook 2013 and 2016? Do I have to do something to make it work with different versions of Outlook?
My Add-In will check some details of the mails and depending on the details it will sort these mails. I guess that should work in all versions.
Is there a clear advantage of an 2013 or 2016 Add-In compared to 2010?
As mentioned in comments by #penleychan, targeting the latest version is a good thought. I did the same when I develop my VSTO addin. Most of the time I have used the common features of the Outlook and developed the addin with template version similar to the installed office (on my machine). Its easy to debug.
If the addin is going use specific feature(s) of a version of Office, then we should use that version template.
You may like to refer this link.
You can run your Office 2010 based solution in later Office versions. You just need to choose the right target .net version. Read more about that in the Running Solutions in Different Versions of Microsoft Office article.
Is there a clear advantage of an 2013 or 2016 Add-In compared to 2010?
The only benefit you get in that case - the PIAs version corresponding to the target Office version. That means you will get access to objects, methods, properties and events available in later Office versions. Anyway, at runtime you still can use the late-binding technology which allows accessing missed members at design-time. See Type.InvokeMember for more information.
I have Visual Studio 2012 Update 1 and office 2010, a git CV system, and an autobuild system based on TeamCity Enterprise. There is a project that contain references to "Microsoft.Office.Interop.Word".
On a new workplace I have installed VS 2015 (update 1) and MS Office 2016. This gave an issue type or namespace 'Office' not found in Microsoft.
I then deleted old references and add new references "Microsoft Office 16.0 Object Library" and "Microsoft Word 16.0 Object Library".
Now, in new Visual Studio 2015 project compiles OK. But the .csproj-file that has been changed is not compiling on other programmers computers, that have VS 2012 or VS 2013.
Is there a way to combine both references for different Office versions?
Alternatively, how can I configure this moment so that it would work fine on all workplaces? Can I just copy old .dll (from Office 2010) to a my computer and add it to project as outer .dll? Or is it bad idea?
Always program against the oldest version of Word (any Office program) that your solution needs to support. Something compiled against version 2016 isn't going to run against 2010 and you might end up using functionality not available in the older version.
It is possible to embed the interop information in your solution, making it PIA version independent (look up "embed interop types" - you need to activate that option for the PIA reference), but the problem with using unsupported functionality remains!
I'm still confused by the different versions of VSTO and in which way they are compatible to office 2007/2010. I know there is a nice table for comparisons on wikipedia, but I still don't get it. My focus lies on PowerPoint.
Okay, so I have the Visual Studio 2010 Professional Edition that provides two templates for PowerPoint: a 2007 Add-In template and a 2010 Add-In template. What exactly is the difference here, is it just the version of the underlying VSTO? Apart form that, is there a difference between VSTO 4.0 and VSTO 2010? Wikipedia uses both terms.
I want the Add-In to work with both PowerPoint 2007 and 2010. Should I chose the 2007 Add-in project type or the 2010 add-in project type?
Wikipedia says: "Office 2007 applications can also use the VSTO 2010 runtime"
and it also says
"VSTO solutions developed against newer Office versions will not work in older Office versions as they lack the necessary Primary Interop Assemblies (PIAs)".
Isn't that some kind of contradiction?
below image should be helpful
A VSTO project will work only with the selected version and later i.e. a 2007 add-in will work with Office 2007 and 2010, whereas a 2010 add-in will work with only 2010.
When deciding which version to choose for an add-in, choose the version of the oldest Office version you want to support.
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.