Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Get worksheet tab names 1

Status
Not open for further replies.

timgerr

IS-IT--Management
Jan 22, 2004
364
US
Hey All,
I am trying to get the name of the worksheet tabs in an excel file. I am not sure what to do. I can read columns and tables, here is my code:
Code:
' Let's open up the excel sheet
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\testscript\excel.xls")


' First thing we need to do is find how many colums there are and what the titles they are
increment = 1
Do Until objExcel.Cells(1,increment).Value = ""
	Wscript.Echo objExcel.Cells(1, increment).Value
	increment = increment + 1
Loop


objExcel.Quit

How can I read the excel worksheet tabs?

Thanks,
-T

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
For i = 1 To objWorkbook.Sheets.Count
WScript.Echo "Sheet" & i & "=" & objWorkbook.Sheets(1).Name
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the information, that worked. One more question, How do I switch workbook sheets?

Thanks again,
-T

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
How do I switch workbook sheets?
To do what ?
Read a cell value ?
Wscript.Echo objWorkbook.Sheets(i).Cells(1, increment).Value

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top