Excel automation and defining a Name for Excel sheet
-
Hi guys, I am using C# to automate some Excel tasks and in it I am defining a name for an Excel sheet using (sheet).Names.Add("TableName", "=Sheet1!$A:$D", Type.Missing... (etc)) and when I open the Excel application that I created it defines the name a litte different than if I was to define it manually. When I define it manually it would be: Names in Workbook: TableName Refers to: =Sheet1!$A:$D Using C# automation it is: Names in Workbook: TableName Sheet1 Refers to: =Sheet1!$A:$D There is an extra right-justified "Sheet1" Appended to the Name!!! Because of that I have no way of referring to that table since it won't recognize it because of that "Sheet1"! I need to access that table using this code: cmdExcel = new OleDbCommand("Select * FROM TableName", cnExcel); But it won't recognize it due to that extra "Sheet1"! SOMEONE HELP! I'll be indebted to you for life! schoudhr@hotmail.com