
getting sheet name in excel
nameof first sheet$ = db.TableDefs(0).Name
No need for the For loop at all.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
Quote:
> sorry wrong email.. my question was how do i read just the first sheet
> sheet name i used this
> For Each def In db.TableDefs
> nameof first sheet$ = def.Name
> exit for
> Next
> is there a better way?
> Dwayne
> > That's exactly what Luke's code is giving you.
> > For Each def In db.TableDefs
> > Debug.Print def.Name
> > Next
> > is going to print out the name of each sheet in the excel file.
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > > I would like to open a database(xls) and import the contents of the
> sheet.
> > > I need to know what the sheets name(s) are in the excel file.
> > > How can I do this?
> > > Dwayne
> > > > Here is a sample in DAO:
> > > > Dim db As DAO.Database
> > > > Set db = OpenDatabase("C:\xl.xls", False, False, "Excel 8.0;")
> > > > Dim def As DAO.TableDef
> > > > For Each def In db.TableDefs
> > > > Debug.Print def.Name
> > > > Next
> > > > Luke
> > > > (This posting is provided "AS IS", with no warranties, and confers
no
> > > > rights.)