VBA Get Workbook Path & Location

VBA Get Workbook Path & Location in Excel

VBA Get Workbook Path in Excel. We deal with multiple workbooks at a time. We may want to know Workbook path and its location. In the following tutorial we will learn to get Workbook complete Path and location using Path and FullName properties of Workbook.

Syntax to Get complete Path of the Workbook in Excel VBA

Here is the syntax of to Get Path of the Workbook in Excel VBA.

expression.Path

Where expression represents Workbook object.
Path represents a property of Workbook. It returns Workbook complete Workbook path.

Macro to Get Path of the Workbook in Excel VBA

Let us see the following macro to get path of the active Workbook in Excel VBA.

'VBA Get path of the active Workbook in Excel
Sub VBA_Get_ActiveWorkbook_Path()
    
    'Variable declaration
    Dim sWorkbookPath As String
    
    sWorkbookPath = ActiveWorkbook.Path
    
    MsgBox "Active Workbook Path is : " & sWorkbookPath, vbInformation, "VBAF1"

End Sub

Here is the output screenshot of above macro.

Workbook Path

VBA Code to Get Location of the current Workbook in Excel

Here is the following VBA Code to Get Location of the current Workbook in Excel.

'VBA Get Location of the current Workbook in Excel
Sub VBA_Get_CurrentWorkbook_Location()
    
    'Variable declaration
    Dim sWorkbookLocation As String
    
    sWorkbookLocation = ThisWorkbook.FullName
    
    MsgBox "Current Workbook Location is : " & sWorkbookLocation, vbInformation, "VBAF1"

End Sub

Let us see the output screenshot of above VBA code.

Workbook Location

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel Blog

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers

2 thoughts on “VBA Get Workbook Path & Location in Excel”

  1. Very nice post. I jᥙst stumbled upon your blog and wished to mentiоn that I’ve really enjoyed browsing your weblog posts.
    Αfter all I’ll be subscribing for your fеed and I hope yoս write once more soon!

Leave a Reply