VBA Excel Get Workbook Name - learnit

Home Top Ad

Post Top Ad

Wednesday, June 9, 2021

VBA Excel Get Workbook Name

VBA Excel Get Workbook Name

What is VBA-Excel

VBA stands for Visual Basic for Applications. Excel VBA is Microsoft’s programming language for Excel and all the other Microsoft Office programs, like Word and PowerPoint. The Office suite programs all share a common programming language.


Why Use Excel VBA?

While users cannot directly manipulate the main Excel software through VBA, they can, however, master the art of making macros to optimize their time in Excel. There are two ways to make Excel macros.


The first method is to use the Macro Recorder. After activating the recorder, Excel will record all the steps a user makes and save it as a “process” known as a macro. When the user ends the recorder, this macro is saved and can be assigned to a button that will run the exact same process again when clicked. This method is relatively simple and requires no inherent knowledge of the VBA code. This method will work for simple processes.



VBA Excel Get Workbook Name

While using Microsoft Excel, you may require to get the workbook name for some purpose and insert the file name into a cell. In this article, we are going to show you methods of getting current workbook name in Excel with details.

Get Current Workbook Name with User-Defined Function

You can get current workbook name with the User-defined function as follows

1. You can get current workbook name with the User-defined function as follows

2. In the Microsoft Visual Basic Application window, click Insert > Module.

3. Copy following code into the Module window.


Example

sub get_workbookname()
Msgbox (Activework.Name)
Msgbbox(ThisWorkbook.Name)
WorkBooks("Book1.xlsx").Activate
Msgbox (ActiveWorkBook.Name)
Msgbox (ThisWorkBook.Name)
End sub

Please Watching My Video is Below

1 comment:

Post Top Ad