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.
Here is the syntax of to Get Path of the Workbook in Excel VBA.
Where expression represents Workbook object.
Path represents a property of Workbook. It returns Workbook complete Workbook path.
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.
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.
You can refer the following link for the step by step instructions.
Click on the following links of the useful resources. These helps to learn and gain more knowledge.