Excel Guides

Getting the Name of the Parent Workbook in Excel

There are a few ways to get the name of the parent workbook in Excel. One way is to use the GetOpenFilename function. This function will return the full path and file name of the workbook that you have open. For example, if you have a workbook named "MyWorkbook.xlsx" open, the GetOpenFilename function will return "C:\Documents\MyWorkbook.xlsx".

Another way to get the name of the parent workbook is to use the ActiveWorkbook property. This property will return a reference to the workbook that is currently active. For example, if you have a workbook named "MyWorkbook.xlsx" open and you make it the active workbook, the ActiveWorkbook property will return a reference to "MyWorkbook.xlsx". You can then use the Name property of the ActiveWorkbook object to get the name of the workbook.

If you want to get the name of the parent workbook from within a macro, you can use the ThisWorkbook object. The ThisWorkbook object represents the workbook in which the code is running. For example, if you have a macro in a workbook named "MyMacroWorkbook.xlsm" and that macro opens another workbook named "DataWorkbook.xlsx", the ThisWorkbook object will represent "MyMacroWorkbook.xlsm" and the ActiveWorkook object will represent "DataWorkook.xlsx". You can use the Nameproperty of the< strong > ThisWorkook object to get t he name of t he parent work book .

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.