RE: Get Excel Worksheet Names for Importing into Access Tables

K

Klatuu

Here is a basic routine that will return all the names of worksheets in a
workbook:

Public Function WorkSheetNames() As Boolean
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = CreateObject("Excel.application")
Set xlBook = xlApp.Workbooks.Open("c:\MyWorkBook.xls", 0, True)
For Each xlSheet In xlBook.Worksheets
Debug.Print xlSheet.Name
Next xlSheet
xlBook.Close False
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
Set xlSheet = Nothing
End Function
 

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