Here is the code that I will use. It does work
Dim ExcelConnection As System.Data.OleDb.OleDbConnection
Try
Dim dt As New DataTable
ExcelConnection = New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=C:\Temp\GL 8-31-06.xls;Extended Properties=Excel 8.0;")
ExcelConnection.Open()
dt =
ExcelConnection.GetOleDbSchemaTable(System.Data.Ol eDb.OleDbSchemaGuid.Tables,
New Object() {Nothing, Nothing, Nothing, "Table"})
Dim oRow As DataRow = dt.Rows(0)
Dim sTableName As String = oRow("TABLE_NAME")
'Alternate Code
For Each oRow In dt.Rows
If dt.Columns.Contains("TABLE_NAME") Then
Debug.Print(oRow("TABLE_NAME"))
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ExcelConnection.Close()
End Try
Thank you
"Paul Clement" wrote:
No. You need the Sheet name and can't use an ordinal (sheet number), which would require one of the
methods that retrieves database schema information.