Hi

Once I wrote below coding it give error meassage.Error meassage is "Member not found".I wrote red color that show the error meassage is occur.

Microsoft.Office.Interop.Excel.Application xl = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook xlWorkBook = (Excel.Workbook)xl.Workbooks.Open("D:\\Test\\VOIP_X.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            Excel.Worksheet xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets("1");
            Excel.Range r  = (Excel.Range)xlWorkSheet.Range("A30", "A30");
             MessageBox.Show(r.Value.ToString());

Thanks
Tank50

Dani AI

Generated

Runtime "Member not found" when using Microsoft.Office.Interop.Excel is almost always a binding/version or bitness issue rather than a problem with the Range call itself. ’s followup (switching to the Office 2003 PIAs) is consistent with that: the COM interfaces your app was compiled against must match what Excel exposes at runtime. Also ensure the process bitness matches the installed Office (most Office installs are 32-bit—set your project to x86).

Quick, practical checklist:

  • Confirm the Excel version on the machine and reference the matching Interop (or rebuild against the PIA you intend to deploy).
  • In Visual Studio, remove/re-add the COM reference and set the Project > Build > Platform target to x86 when Office is 32-bit.
  • For .NET 4+, consider Embed Interop Types carefully (it can help or hide version issues depending on calls used).
  • Guard against nulls when reading cell values and prefer Value2 if you need the raw underlying value.

If this code runs in ASP.NET or on a server, do not rely on Office automation—Microsoft advises against server-side Office automation. For robust, supported reads consider alternatives that don’t require Excel to be installed: Open XML SDK for .xlsx, EPPlus (xlsx), ExcelDataReader (xls/xlsx) or NPOI. These are safer for web apps and services and avoid the PIA/bitness problems.

Example patterns (not Interop): using OleDb for legacy .xls or ExcelDataReader for both formats.

// OleDb (legacy .xls)
string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.xls;Extended Properties='Excel 8.0;HDR=NO;IMEX=1';";
using(var cn = new OleDbConnection(conn)) {
  cn.Open();
  using(var cmd = new OleDbCommand("SELECT F1 FROM [Sheet1$A30:A30]", cn))
  using(var r = cmd.ExecuteReader()) { if (r.Read()) { var val = r.GetValue(0); } }
}
// ExcelDataReader (nuget) - reads both xls/xlsx
using(var stream = File.Open(path, FileMode.Open, FileAccess.Read))
using(var reader = ExcelDataReader.ExcelReaderFactory.CreateReader(stream)) {
  var ds = reader.AsDataSet();
  var value = ds.Tables[0].Rows[29][0]; // row 30, column A
}

References: Microsoft guidance on server-side Office automation and libraries: Considerations for server-side Automation of Office, ExcelDataReader, EPPlus, Open XML SDK.

Recommended Answers

All 4 Replies

Check the below article. Sure it will help

Hi

I think its for create new excel file,but I need to read excel file

Thnaks
Tank50

oRng.Cells(nRows, nCols).Value

By using the above line, you can read as well.

HI

Previously I had Microsoft office 2007,so I installed office 2003 and I used Microsoft 11.0 object Library.Now Its working,

Thanks
Tank50

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.