The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)

Hi,

I am using Microsoft Visual Studio.NET 2003. I am trying to do somw work with EXCEL and keep getting the following error.

The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)

I have added the following to the project:

Microsoft Excel 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft XP PIA's


the following is my code but it doesn't seem to recognise        using Excel;
Wwould appreciate any help.

using System;
using Excel;
using System.Collections;


namespace exer
{
      class ExcelClass
      {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            private string Cfilename;
            public    Excel.Application excelApp ; // Creates a new Excel Application
            public Excel.Workbook excelWorkbook;
            public Excel.Sheets excelSheets;
            public Excel.Worksheet excelWorksheet;

            public void Start(string filename)
            {
                  Cfilename=filename;
                  excelApp = new Excel.ApplicationClass();
                  excelWorkbook = excelApp.Workbooks.Open(filename, 0,
                        false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true,
                        false,  0, true, false, false);
            }          
            public void openSheet(string currentSheet)           // The following gets the Worksheets collection
            {
                                   
                  excelSheets = excelWorkbook.Worksheets;
                                   
                  excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
            }
            public void setcell(string val)
            {
                                   
                  // The following gets cell A1 for editing
                  excelSheets = excelWorkbook.Worksheets;
                  Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1");

                  // The following sets cell A1's value to "Hi There"
                  excelCell.Value2 = val;
            }
            public void view()
            {
                  excelApp.Visible=true;// Makes Excel visible to the user.
            }
            public void Close()
            {
                  excelWorkbook.Close(false,Cfilename,false);
                  excelApp.Quit();
                  excelApp=null;
            }

      }

gmoconnoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

e1vCommented:
try
 using Excel = Microsoft.Office.Interop.Excel;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gmoconnoAuthor Commented:
Thanks alot e1v. No more errors. A bit new to this thing.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.