excel vba current path code example

Example 1: excel vba get the path of current workbook

'VBA function to retrieve this workbook's full path:

Function FullPath()
    With ThisWorkbook
        FullPath = .Path & Application.PathSeparator & .FullName
    End With
End Function

'--------------------------------------------------------------------

MsgBox FullPath

Example 2: excel vba current folder

' Current folder
MsgBox ActiveWorkbook.Path      ' needs to be saved before
MsgBox CurDir					' default

Tags:

Vb Example