Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot create an instance of the abstract class or interface 'Excel.Ap

Status
Not open for further replies.

AT76

Technical User
Apr 14, 2005
460
US
Hi,

I'm trying to access an excel sheet in my machine thru C# via ASP.NET. I keep getting the above error message (see subject). I have added the following references:

Microsoft Excel 11.0 Object Library
Microsoft Office 11.0 Object Library

Here's the code I have:

private void Button1_Click(object sender, System.EventArgs e)
{
//Excel.Application objExcel = new Excel.Application();
Excel.Application ObjExcel = null;
ObjExcel = new Excel.Application();

if (ObjExcel == null)
{
MessageBox.Show("Error opening the Excel Application");
Application.Exit();
}

//Make the Application Visible
ObjExcel.Visible = true;

}

The error I previously mentioned points to NEW (bold). Any suggestions how I can successfully create the excel instance.

Thank you!
 
Why did you post 2 threads for the same issue?

You will need only Microsoft Excel 11.0 Object Library.
Is the application for internet or intranet?
 
The 2 threads was an accident. My apologies for that. I did not know how to delete 1 of them.

I tried it with only Microsoft Excel 11.0 Object Library but I get the same error message.

This application will be for use via intranet.

Thanks...

 
OK,

I was able to fix it but have not been able to open the excel file yet.

Here's my code so far:

private void Button1_Click(object sender, System.EventArgs e)
{

Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Worksheet ObjWS;

ObjExcel.Visible = true;
ObjExcel.DisplayAlerts = false;

ObjExcel.Workbooks.Add("");
object strPathExcel = "c:\\Wk16.xls.xls";
ObjExcel.Workbooks.Open(strPathExcel);
object ObjW = ObjExcel.ActiveWorkbook;

ObjWS = ObjExcel.Worksheets("sheetName");

ObjExcel.Quit();
ObjExcel = null;
}

1st error: "No overload for method 'Open' takes '1' arguments" ; error occurs when trying to open the excel ws

2nd error: "'Microsoft.Office.Interop.Excel._Application.Worksheets' denotes a 'property' where a 'method' was expected"

Thank you in advance for any help provided.

AT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top