How do you reference MS office interops in C#? - c#

I am trying to access Outlook 2007 from C#. I have installed the PIA msi after following the directions found on msdn. After a successful install nothing shows up in Visual Studio's references under the .net tab.

Office interaction is available through COM objects found on the 'COM' tab of the 'Add Reference' dialog window.

After you downloaded the installer and ran it, did you run the MSI installer it extracted and placed in the folder it asked you to create?

Related

Can I build a project referencing Office 2013 COM components without installing Office 2013?

We have a small project that references Microsoft.Office.Interop.Word 8.6.0.0. The reference was added via the COM tab in the Add References window, so the underlying .csproj reference is a COMReference.
I'm trying to set up a build server at the moment, and according to the answer to this question, it's no longer possible to work directly with Office 2013 PIAs.
This is incredibly frustrating as I don't want to have to deploy an instance of Office to my build server. Is there any way to achieve what I'm trying to do without installing Office?

Cannot find Microsoft.Office.Interop Visual Studio

I am developing an application which will send emails using C#. The app will be able to use templates for mail, among other things. The problem is I'm having trouble finding any Office.Interop references, which means I cannot work with Outlook.
Office is installed on my computer, but I've also tried to install the PIA from this link http://www.microsoft.com/en-us/download/details.aspx?id=3508. Unfortunately, this didn't change anything: When I launch the MSI it stops without a word, and I don't know if that is part of the problem.
Look for them under COM when trying to add the references. You should find the reference below, and possibly Microsoft Outlook 15.0 Object Library, if you need that. There are similar libraries for Word, Excel, etc.:
Update: The Object Library should contain the Interop stuff. Try to add this to a source file and see if it can now find what you need:
using Microsoft.Office.Interop.Outlook;
I forgot to select Microsoft Office Developer Tools for installation initially. In my case Visual Studio Professional 2013 and also 2015.
If you're using Visual Studio 2015 and you're encountering this problem, you can install MS Office Developer Tools for VS2015 here.
With Visual Studio 2015 I have activated it with the following steps.
Programs and Features --> Select Visual Studio > Change
Choose Modify
Windows and Webdevelopment --> Tick/select "Microsoft Office Developer Tools"
Start Update
It should work now.
You can find it at link:
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll
Browse it then add references
If you have installed latest Visual studio and want to
To locate library of Microsoft.Office.Interop.Outlook or any other Microsoft.Office.Interop library then you should look into below 2 folders:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office14
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15
Please note that folder could be C:\Program Files\
I think you need to run that .msi to install the dlls. After I ran that .msi I can go to (VS 2012) Add References > Assemblies > Extensions and all of the Microsoft.Office.Interop dlls are there.
On my computer the dlls are found in "c:\Program Files(x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA" so you could check in a similar/equivalent directory on yours just to make sure they're not there?
You need to install Visual Studio Tools for Office Runtime Redistributable:
http://msdn.microsoft.com/en-us/library/ms178739.aspx
I had the same issue with Visual Studio Community 2013, I fixed it downloading and installing the latest update of Office Developer Tools for Visual Studio 2013. Now I am able to see the whole Microsoft.Office.Interop.* list when I go to
Add References > Assemblies > Extensions
you can download it from here:
https://www.visualstudio.com/en-us/news/vs2013-update4-rtm-vs.aspx#Office
http://aka.ms/OfficeDevToolsForVS2013
Just doing like #Kjartan.
Steps are as follows:
Right click your C# project name in Visual Studio's "Solution Explorer";
Then, select "add -> Reference -> COM -> Type Libraries " in order;
Find the "Microsoft Office 16.0 Object Library", and add it to reference (Note: the version number may vary with the OFFICE you have installed);
After doing this, you will see "Microsoft.Office.Interop.Word" under the "Reference" item in your project.

Microsoft.Office.Interop.Outlook 2010 Reference in VS 2012 Using .Net 2.0

I was tying to add a Reference to Microsoft.Office.Interop.Outlook Namespace in to my web project i'm using .Net 2.0 And visual studio 2012
Question
Which one of the following is the one i should choose to work with Outlook 2010
I tried to google this and i couldn't find any thing
Or here is GAC path
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Outlook\14.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Outlook.dll
you can browse manually to folder
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Outlook\14.0.0.0__71e9bce111e9429c\
and consequently choose Microsoft.Office.Interop.Outlook.dll
You've chosen wrong tab in Reference Manager. Choose this tab:
Then find Microsoft.Office.Interop.Outlook library. If you have multiple choice, then look at File Version info - there's a version of Office you can work with: 12.* - 2007, 14.* - 2010, 15.* - 2012.
The best choice is 14.* but the others will mostly work too.
I also need to worry you that Microsoft suggests not to use interop on server side (link)

How to install/deploy VSTO Excel 2010 Addin developed in C#.net?

I have developed an excel addin using VSTO in C#.net .Now i want to deploy this addin in other machines too .So that users who installed this can see my addin in excel menu -> Addins-> MyAddin
Alternatively can i give them just Excel with myaddin.So that whoever has this Excel can access addin and use it.This way they don't see myaddin in every excel file addins menu.
You can use a Visual Studio 2010 setup project to create a Windows Installer package. See this MSDN Link
Quote from that Link
Summary: Learn how to deploy a Microsoft Visual Studio Tools for the
Office system 2010 add-in or document- level solution using a Visual
Studio 2010 setup project to create a Windows Installer package that
targets the 2007 Microsoft Office system or Microsoft Office 2010.
Wouter van Vugt, Code Counsel
Ted Pattison, Ted Pattison Group
This article was updated by Microsoft with permission from the
original authors.
Applies to: Visual Studio 2010 Tools for Office, 2007 Microsoft Office
system, Microsoft Office 2010, Visual Studio 2010.
Download: http://code.msdn.microsoft.com/VSTO2010MSI
Contents
Overview
Deployment Methods
Deploying Office solutions that target the Visual Studio 2010 Tools for Office runtime
Download Samples Provided with this Article
Creating a Basic Installer
Conclusion
Additional Resources
About the Authors
EDIT
You may also see this link for All Users.
Conceptually, all you need to concentrate on is get yourself a COM object created which must be running even when the application (MS Excel here) is not open in the explorer.
More can be figured out from the following link :
http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C
(P.S : link is for c# not c).
Next you should give your users a .exe file including code to create the COM object.

Outlook COM Addin bundle install with a seperate msi file C#

I'm trying to be able to bundle an Outlook addin (.dll file) that I've made in C# with a separate msi installer (not the default one created in Visual Studio). The add-in works great using the default setup that Visual Studio creates but I'm looking to install the .dll file using a different msi as to bundle it with another piece of software and I'm not sure what registry values or other details need to be worked out that will allow Outlook for recognize the addin. Thanks for any help!
Please take a look at this tutorial.
http://msdn.microsoft.com/en-us/vsto/ff937654.aspx

Categories

Resources