View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default returning workbook name

msgbox ActiveWorkbook.Name
this returns the name of the currently active workbook

msgbox ThisWorkbook.Name
this returns the name of the workbook that is running the code

So if code is running in Book1 but book2 is active, then the first msgbox
gives Book2 and the second gives Book1

x=3
msgbox Workbooks(x).Name



DIM WB as Workbook
FOR EACH WB in Workbooks
Debug.Priint WB.Name
NEXT



"Saladin" wrote:

Hi

How do I return the name of my current workbook in code? Just the name ...
path not essential.

Thanks
Graeme