getting sheet name in excel 
Author Message
 getting sheet name in excel

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



Sun, 27 Jun 2004 13:08:02 GMT  
 getting sheet name in excel
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.)



Mon, 28 Jun 2004 11:02:46 GMT  
 getting sheet name in excel
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


Quote:
> 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.)



Wed, 30 Jun 2004 15:47:47 GMT  
 getting sheet name in excel
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


Quote:
> 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.)



Wed, 30 Jun 2004 19:57:43 GMT  
 getting sheet name in excel
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



Quote:
> 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.)



Thu, 01 Jul 2004 09:45:34 GMT  
 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.)



Thu, 01 Jul 2004 08:46:46 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Getting the list of Excel Sheet Names using VBA

2. getting the name of the active sheet (Excel)

3. Getting excel sheet names with DAO

4. Getting excel sheet names with DAO

5. getting previous cell values in excel sheets

6. Getting the RIGHT Excel sheet with OLE automation - AddOLEObj

7. how getting data from EXCEL.sheets

8. VB 3.0 PRO/EXCEL/DDE Getting info from different sheets

9. Excel Sheet Name

10. Use VBA to send Task Folder name to an Excel Sheet

11. Accessing Excel Sheet Names in VB 4.0

12. Changing name on Excel sheet

 

 
Powered by phpBB® Forum Software