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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename active Excel worksheet

Status
Not open for further replies.

MePenguin

Technical User
Oct 31, 2003
107
SE
Can any one tell me how to rename the active worksheet - more specifically the one just created?
At the moment I have
Code:
Dim ObjExcel As Object
Set ObjExcel = GetObject(Filename)

    ObjExcel.Application.Worksheets.Add
    Sheetname = "Sheet" & row - 1
    ObjExcel.Application.Worksheets(Sheetname).Name = 
_ArraySheetFldNames(row)

... which does not work on non-English versions of Excel (as the default sheet name is not "sheet...").

Thanks

Phil
 
Here I go, answering my own questions again!

Code:
Dim ObjExcel,ObjNewSheet As Object
Set ObjExcel = GetObject(Filename)
    Set ObjNewSheet = ObjExcel.Application.Worksheets.Add
    ObjNewSheet.Name = ArraySheetFldNames(row)

Hope that helps someone else as well...
 
Replace this:
Dim ObjExcel,ObjNewSheet As Object
By this:
Dim ObjExcel As Object, ObjNewSheet As Object

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
It seems to work with either declaration for me, but I've encountered multiple variable dim problems elsewhere.

I'll achange it to be on the safe side.
Thanks for the tip!

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top