Tuesday, February 15, 2011

Get Sub Excel Name

Dim objExcel
Dim oSheet
'Create an object for Excel Application
Set objExcel = WScript.CreateObject("Excel.Application")
Set temp = objExcel.Workbooks.Open("C:\Documents and Settings\deepakpe\Desktop\Mine_doc\new.xlsx")

MsgBox temp.Worksheets.Count
MsgBox temp.Worksheets.Application


'Loop get the name of sub excel

For Each oSheet In objExcel.Worksheets
    WScript.Echo oSheet.Name
    MsgBox oSheet.name
Next

objExcel.Workbooks.Close ()
objExcel.Quit

'Release the object

Set objExcel = Nothing

No comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | JCpenney Printable Coupons