Get Excel Sheet Name

I want to get user-specified sheet name for his/her Excel file through VB code. Any help is appreciated.
guosongAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
msgbox YourExcelObject.ActiveSheet.Name
0
EDDYKTCommented:
I assume you know how to open excel file and create an Excel object.


    dim XlApp As Excel.Application
    Dim WS As Worksheet, Wsh As Sheets
   
    On Error Resume Next

    ' Open xlapp objet
    Set Wsh = XlApp.Workbooks(TmpFileName).Sheets
    If Wsh Is Nothing Then GoTo ExitNow
    If (Wsh.Count < 1) Then Exit Sub
    For Each WS In Wsh
        debug.print  WS.Name
    Next
   
ExitNow:
    Set Wsh = Nothing


where tmpfilename is your excel file name
0
sivaramyCommented:
You can use ActiveWorkBook.Fullname to get the file name with path.
0
SwordSaintCommented:
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet
dim name as string

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add(filepath)
Set xlSheet = name
'name = the name get from the inputbox

xlApp.Visible = True

'I leave the code to get data from the input box to you because I don't have the VB now. Hope this solve your problem.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.