Return to VBA Code Examples

VBA CurDir Function

CurDir Description

Returns the current path.

Simple CurDir Examples

Assume current path on C drive is “C:\Windows”

Assume current path on D drive is “D:\MyFolder”

Assume current drive is C drive.

MsgBox CurDir
MsgBox CurDir("C")

Result: “C:\Windows”

MsgBox CurDir("D")

Result: “D:\MyFolder”

CurDir Syntax

In the VBA Editor, you can type  “CurDir(” to see the syntax for the CurDir Function:

The CurDir function contains an argument:

Drive: [Optional] A string expression representing a directory. If ommitted the current directory is used.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!
vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples