ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Identify Workbook (https://www.excelbanter.com/excel-programming/299456-vba-identify-workbook.html)

No Name

VBA Identify Workbook
 
I need to write a macro that resides in workbook A. Using
Set fromarea = Application.InputBox("Where is the source
data?", , , , , , , 8)
fromarea.parent.name gives me the name of the worksheet
that I referenced (in another workbook). I need a way to
identify the workbook name as well. It is not
activeworkbook or thisworkbook.

Thanks.

Harald Staff

VBA Identify Workbook
 
Hi

It's strictly hierarchial:
fromarea.parent.parent.name
(or path or fullname or whatever WB property)

HTH. Best wishes Harald


skrev i melding
...
I need to write a macro that resides in workbook A. Using
Set fromarea = Application.InputBox("Where is the source
data?", , , , , , , 8)
fromarea.parent.name gives me the name of the worksheet
that I referenced (in another workbook). I need a way to
identify the workbook name as well. It is not
activeworkbook or thisworkbook.

Thanks.




Paulw2k

VBA Identify Workbook
 
fromarea.parent.parent.name Or fromarea.worksheet.parent.name

will give you the workbook name.



wrote in message
...
I need to write a macro that resides in workbook A. Using
Set fromarea = Application.InputBox("Where is the source
data?", , , , , , , 8)
fromarea.parent.name gives me the name of the worksheet
that I referenced (in another workbook). I need a way to
identify the workbook name as well. It is not
activeworkbook or thisworkbook.

Thanks.





All times are GMT +1. The time now is 12:28 AM.

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