Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Retieve Workbook Name via code
Is there some code that will retrieve a workbook name?
What I'm trying to do within some code (in an xl template) is to activate the workbook again after the procedure has done some activity in another workbook. But the workbook that has the code in it doesn't always have the same name. Rob |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Retieve Workbook Name via code
Hi,
This puts all open workbook naames in a message box which you should be able to adapt:- Sub seeemall() Dim wkb As Workbook For Each wkb In Workbooks If Windows(wkb.Name).Visible Then _ MsgBox (wkb.Name) Next End Sub Mike "RobN" wrote: Is there some code that will retrieve a workbook name? What I'm trying to do within some code (in an xl template) is to activate the workbook again after the procedure has done some activity in another workbook. But the workbook that has the code in it doesn't always have the same name. Rob |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Retieve Workbook Name via code
The best way is to set a variable pointer to the workbook, then reclaim it
so to speak Set myWb = Activeworkbook ... 'do your other stuff ... myWB = Activeworkbook Even better (than the best? uhm?), is to refernce the workbooks by these object variables all the time Set myWb = Activeworkbook With myWB 'do some stuff End With Set oWB2 = Worksbooks.Open(wbfilename) With oWB2 'do your other stuff Ene With With myWB 'etc -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "RobN" wrote in message ... Is there some code that will retrieve a workbook name? What I'm trying to do within some code (in an xl template) is to activate the workbook again after the procedure has done some activity in another workbook. But the workbook that has the code in it doesn't always have the same name. Rob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
workbook code | Excel Worksheet Functions | |||
VBA code is being deletd from WorkBook | Excel Discussion (Misc queries) | |||
copy and paste using code from workbook to workbook | Excel Discussion (Misc queries) | |||
Code for workbook protection | Excel Discussion (Misc queries) | |||
Often-Used Code not working in a new Workbook | Excel Discussion (Misc queries) |