CurDir Function

Description

Returns a Variant (String) representing the current path.

Syntax

CurDir[(drive)]

The optional drive argument is a string expression that specifies an existing drive. If no drive is specified or if drive is a zero-length string (" "), CurDir returns the path for the current drive.

See Also

ChDir statement, ChDrive statement, MkDir statement, RmDir statement.

Specifics (Macintosh)

The optional drive argument is a string expression that specifies an existing drive. CurDir ignores any drive specified and simply returns the path for the current drive.

Example

This example uses the CurDir function to return the current path.

' In Microsoft Windows:
' Assume current path on C drive is "C:\WINDOWS\SYSTEM".
' Assume current path on D drive is "D:\EXCEL".
' Assume C is the current drive.
Dim MyPath
MyPath = CurDir    ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("C")                    ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("D")                    ' Returns "D:\EXCEL".
' On the Macintosh:
' Drive letters are ignored. Path for current drive is returned.
' Assume current path on HD Drive is "HD:MY FOLDER".
' Assume HD is the current drive. Drive MD also exists on the machine.
Dim MyPath
MyPath = CurDir                            ' Returns "HD:MY FOLDER".
MyPath = CurDir("HD")                    ' Returns "HD:MY FOLDER".
MyPath = CurDir("MD")                    ' Returns "HD:MY FOLDER".