Learn Excel - Simplify Life with Excel Concepts

Excel CurDir Function (VBA)

CurDir Function VBA Code

How to use the CurDir Function (VBA)

This Excel tutorial explains how to use the Excel CurDir function with syntax and examples using VBA.

SUMMARY:

The Excel VBA CurDir function returns the current path of a given drive (String).

PURPOSE:

To get the current path.

RETURN VALUE:

The CurDir function returns a string value.

SYNTAX:

CurDir [ (drive) ]

ARGUMENTS:

The CurDir function syntax has the following arguments:

  • drive: Optional. The 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.
    • On the Macintosh, CurDir ignores any drive specified and simply returns the path for the current drive.

REMARKS:

  • If "drive" = "", then the current drive is returned.
  • If "drive" is left blank, then the current drive is returned.
  • You can use the CURDIR$ function to return a String data type instead of a Variant/String data type.

Useful Links: Link 1Link 2Link 3Link 4