cannot use Microsoft.Office.Interop.Word - c#

I'm trying to use the namespace Microsoft.Office.Interop.Word and implement the code here
But Office is marked with a zig-zag red line as a not identified type
Any one know how should I include this library ?

You can get and include the interop assemblies from here:
http://www.microsoft.com/en-us/download/details.aspx?id=3508

You need to add a reference in your project. Go to Solution Explorer, right-click "References", choose "Add reference..." and pick the appropiate reference, e.g. Microsoft.Office.Interop.Word.

You should have Microsoft office installed on your machine

Related

Add Dynamics GP namespaces Visual Studio project

I need to add the following namespaces
• Microsoft.Dynamics.Common
• Microsoft.Dynamics.Common.Types
• Microsoft.Dynamics.GP.BusinessLogic
• Microsoft.Dynamics.Common
• Microsoft.Dynamics.GP
to my project in Visual Studio,
Kindly suggest how I can do so.
First you need to add references to the libraries to your project. Right click the project name and select "Add Reference" or if the project shows a references folder right click that and choose to add. If the library doesn't show in the list then browse to where ever it is located and select it.
Then at the top of the file add a using command. For example:
using Microsoft.Dynamics.Common;
Please feel free to post additional questions.
Either Download and install the SDK on your machine, It will include the dlls needed to integrate with dynamics or copy the dlls from where ever you have them. (make sure you get the correct version for GP). From there you should create a folder in your project to hold the files in one place and copy them there. Once you have the library files you add references to the files by going to the browse sections of the reference manager and then browsing to the where you copied the files. (Quick note. make sure that you set copy local to true so that it will include the files locally when running and not look for them in the GAC). Once referenced you should be able to access the namespaces and include them with using keyword as needed.
If in case you are not getting the required dlls even after installing SDK, then add required Nugets online in visual studio(and later). After that you can start using the keyword "using" in your VS project.

adding Microsoft.Office.Interop.Excel reference

I am attempting to write a c# script that performs work on an excel spreadsheet. (Rather then a VBA macro). I am trying to add the reference to the Microsoft.Office.Interop.Excel assembly. I cannot find any reference to said assembly in the Add Reference... Window or by browsing to C:\Windows\assembly\GAC. It does not exist. I uninstalled and reinstalled office, and I also downloaded and installed the PIA redistributable located here. The Microsoft.Office.Core is the closest assembly I found, added via COM -> Microsoft Office 14 / 15 Object Library. Any comments or advice appreciated.
I see a copy under C:\Windows\assembly\GAC_MSIL. Is it there for you?
If that doesn't work, open Windows Command Processor and use
dir /s microsoft.office.interop.excel.*
In my C# project, the path is
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\14.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll
I am using Excel 2010
You might want to have a look at a related post.

How can I integrate C# libraries into Visual Basic?

There are some libraries written in C# that I would like to use in Visual Basic, but I can't find any tutorials or anything giving me any clues as to how it is done. I have compiled (I think) the library, but I have looked everywhere (including the project properties) for a solution with no success.
If they are in the same solution, just "Add Reference" and select the C# project. If not, compile them into a .dll and "Add Reference" -> select the path to it.
You should then be able to 'Include' / 'Import' methods, classes and objects from the C# projects / libraries.
If you have compiled your C# code into a DLL, you should be able to reference it in a VB.NET project as you would any other DLL. Include your DLL somewhere in your project's folder structure (typically in a "lib" folder), then do the following:
Open your C# project in Visual Studio.
Right click on "References" in the Solution Explorer and click on "Add Reference."
Select the "Browse" tab, then browse to - and select - the desired DLL.
For more information on adding and removing references, visit this article.
You can just add it to your VB.Net project as reference and then use it. Once code is compiled (VB.Net or c#) its in IL(intermediate language) so there is no difference. Look at the example I gave in the answer of following question. I have done exactly what you are asking for.
Can C# compiler compile a VB.Net code?
You can find out how to add reference by going to below URL:
http://msdn.microsoft.com/en-us/library/7314433t(v=vs.90).aspx

Finding namespace and libraries in VS 2010

I need following namespaces to use native wpf property grid however, VS 2010 doesn't recognize them. I went over available namespaces and libraries under "Add Reference" but no luck.
An suggestions will be appreciated.
System.Activities
System.Activities.Core.Presentation
System.Activities.Presentation
Thank you.
This dll available is this location, on a 64-bit OS.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
The best way to find what DLL to add is to check with MSDN Library
Find the help for the class you need. Ex: System.Activities.Activity
On the page, look for the assembly name. It is locate in the top part of the page and in bold. Ex : Assembly: System.Activities (in System.Activities.dll)
Add the reference to the DLL that is between the parentheses and you will have access to the namespace.

How do I include System.Windows.Shapes?

I am using Visual Studio 2008 with the .NET Framework (v3.5). I cannot seem to use System.Windows.Shapes, or anything System.Windows.* besides Forms.
Here is the link to the class description:
System.Windows.Shapes (MSDN Library)
Is there some special thing I need to do to use it?
I checked in all of the framework folders, and the only dll/xml files I have for System.Windows is System.Windows.Forms.
What do I need to do to get this to work?
This class is part of WPF, from MSDN:
Shape Class
Assembly: PresentationFramework (in presentationframework.dll)
You need to add a reference to the PresentationFramework library.
In VisualStudio, right click on your project in the "Solution Explorer". Select "Add Reference". The "PresentationFramework" library will be under the ".NET" tab. You may also need to add "PresentationCore" and "WindowsBase".
You can see your project's current library references by going to the "Solution Explorer" and expanding the "References" item.
You may need to add a reference to the library, probably System.Windows.Presentation
Edit: It is in the PresentationFramework library
Add reference to PresentationFramework from .Net tab
write using System.Windows.Shapes
and you are done!
Other solution that works in .Net 4.0:
Go to referenes->add reference and choose PrsentationFramework under .NET tab.

Categories