I'm seeking some vbscript code in order to grab all the worksheet names from an excel file, anyone got any suggestions, pointers. I am able to query the actual worksheets when hard coded but how do you select the worksheets. hmmmmm........
Set objXL = WScript.CreateObject("EXCEL.application"
' objXL.Visible = True
Set objWkBook = objXL.WorkBooks.Open "YourExcelFile"
Set colSheets = objWkBook.Sheets
For Each Sheet In colSheets
wscript.echo Sheet.Name
Next
thanks for the reply, is that some VB code? I have never come across the WScript.CreateObject.
The code threw an error on the workbooks.open "form1.xls"
(my xl filename)
Expected end of statement
shoud the whole path be in there?
Set objXL = WScript.CreateObject("EXCEL.application"
' objXL.Visible = True
Set objWkBook = objXL.WorkBooks.Open ("form1.xls"
Set colSheets = objWkBook.Sheets
For Each Sheet In colSheets
wscript.echo Sheet.Name
Next
I also tried it with brackets which didn't throw an error but did not output anything.
Can you help me out? Where can I find some info on that WScript object?
Had to change the code a little for asp but all seems good.
Thanks so much for your tip.
here for anyone else who is interested is the code snip
Set objXL = CreateObject("EXCEL.application"
' objXL.Visible = True
Set objWkBook = objXL.WorkBooks.Open ("C:\localpath\form1.xls"
Set colSheets = objWkBook.Sheets
For Each Sheet In colSheets
Response.write Sheet.Name
Next
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.