【VBA】Get the path and file name of a running workbook

You can get
the “path” and “file name” of a running workbook“!

PR

VBA Code

You can get “Workbook object” by “ThisWorkbook property” of “Application Object“.

You can get the “path” and “file name” of a running workbook“ by “method” of “Workbook Object“.

Option Explicit

Sub sampleProc()
    
    'Get the path and file name of a running workbook
    MsgBox "path of a running workbook   :" & ThisWorkbook.Path & vbCrLf & _
           "file name of a running workbook:" & ThisWorkbook.Name
    
End Sub
PR

Result

You got the “path” and “file name” of a running workbook“.

Result
Result
PR

FYI

For more information about following, see the following official online manual:

ThisWorkbook property” of “Application Object


●”Workbook Object”

タイトルとURLをコピーしました