Click here to Skip to main content
14,872,070 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi Friends

I am stuck up with a problem.I would be grateful to you people if anyone of you help mein solving my problem.

Actually I want to invoke an Excel application through my C# .Net program.For that I added the

using Excel= Microsoft.Office.Interop.Excel;

For that I did as below-->

My application->RC->Add Referenece->COM->Microsoft Excel 12.0 Object Library.

I did not find Microsoft.Office.Interop.Excel;

Now at Complie time I am getting a error as-->

The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Am I missing anything or doing something wrong?
Can anybody help me for solving this problem??

Thanking in Advance.

Swapnil Borkar
(Software Trainee)
Posted
Updated 9-Mar-10 19:40pm
v2

VB
AddReference->.NET->
Microsoft.Office.Interop.Excel.
   
You need also to add a reference to the Microsoft Office 12.0 Object Libray, for the base support for office interop. See this article[^] for more information.
   
v2
I don't think you want to add a reference to the COM library if you're using C#. You want the Primary Interop Assemblies, but you'll have to check the MSDN documentation for where to find them. I think their presence also depends on the version of Visual Studio you're using (I don't think the Express editions include them, for example).

A good place to start might be creating an Office plug-in project in Visual Studio and seeing what the references end up being.

Altenrativly, have a look in Object Browser to see what namespace the Excel Object Library has been put in. Be warned, however, that this is not the recommended way of doing things.
   
Add the "Microsoft.Office.Interop.Excel.dll" to your C# project reference from the following path

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Excel.dll
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900