
Getting Excel worksheet names using DAO.
Sure,
They show up as "tables"
Steve
Public Sub ExcelOpenWbAsTable()
On Error GoTo ProcError
Dim db As Database
Dim tdf As TableDef
Dim strFile As String
strFile = "c:\temp\sample.xls"
Set db = OpenDatabase(strFile, False, False, "Excel 5.0;HDR=NO;IMEX=2;")
For Each tdf In db.TableDefs
MsgBox tdf.Name 'show sheet name
Next
Set db = Nothing
Exit Sub
ProcError:
Select Case Err.Number
'Case 3265 'Application-defined or object-defined error
' Resume Next
Case Else
MsgBox "Unanticipated error: " & Err.Number & " " & Err.Description
Stop
Resume 0
End Select
End Sub
Quote:
> Is there a way to use DAO to get the worksheet names in a Excel file?
> TIA.
> Pat Green
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----