0

Hi!

I try to open an existing excel file and have included namespaces and libraries as well but the highlighted words show errors. Please help.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel;
using Microsoft.Office.Interop.Excel;
 

namespace excel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application excelApp = new Excel.ApplicationClass();
            excelApp.Visable = true;
            Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,
        0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
        true, false, 0, true, false, false);
        }

        
    }
}
2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Teme64
0

If you're using a namespace using Microsoft.Office.Interop.Excel; you can't refer to types as Excel.Application or Excel.Workbook . You use just Application and Workbook.

Application is a reserved word in .NET. Use _Application or Microsoft.Office.Interop.Excel.Application instead.

HTH

0

Hi! Nice to hear that you got answer to your problem. Could you please mark the thread as solved. Thank you!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.