Importing Excel File, but don't know Sheet Name

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
 
B

Bob

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
 
D

david epsom dot com dot au

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

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top