The VBA CurDir function returns the current path as a String.
The syntax of the function is:
If the [Drive] argument is omitted, the CurDir function returns the current path on the current drive.
Note: If you are using a Macintosh device, the [Drive] argument is ignored and the CurDir simply returns the current path on the current drive.
The example code below shows the VBA CurDir function used to return the current paths on the C: drive and the F: drive of a PC.
' Return the current path on different drives on the current PC.
' (Note that the current drive is the C drive).
Dim path1 As Stringpath2 = CurDir( "F" )
Dim path2 As String
' path2 is now equal to the String "F:\Projects".
Note that in the above vba code:
If the first letter of the supplied [Drive] argument does not relate to an existing drive on the current system, you will get the error: