ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   returning workbook name (https://www.excelbanter.com/excel-programming/326595-returning-workbook-name.html)

Saladin

returning workbook name
 
Hi

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

Thanks
Graeme



OJ[_2_]

returning workbook name
 
MsgBox ActiveWorkbook.Name


augustus

returning workbook name
 
application.ActiveWorkbook.Name

"Saladin" wrote:

Hi

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

Thanks
Graeme




Patrick Molloy[_2_]

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




Saladin

returning workbook name
 
Gosh that was quick! Thanks all.
"Patrick Molloy" wrote in message
...
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







All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com