Importing Excel File, but don't know Sheet Name

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hi,

I want to import an excel file to an access table, but I
don't know the name of the worksheet. Is there a way of
getting this information, like I would with a TableDef for
an Access table?

Cheers
 
Try:

Sub GetSheetNames()
Dim dbs As Database
Dim rst As Recordset
Dim intNumRecords As Integer
Dim tdfLinked As TableDef
Dim temp As String

Set dbs = OpenDatabase("c:\test.xls", False,
False, "Excel 5.0;HDR=No;")

Set tdfLinked = dbs.CreateTableDef("hmm")
For Each tdfLinked In dbs.TableDefs

temp = tdfLinked.Name
Debug.Print temp

Next tdfLinked

End Sub
 
Also, you can normally import the first sheet,
even if you don't know it's name.

(david)
 
Back
Top