VBA ChDir function

ChDir function Description

The VBA ChDir function changes the current directory. The ChDir function does not change however the current drive – scroll down to learn more.

Syntax

The syntax for the ChDir function is:

ChDir( path )

Parameters

path
The path (directory) you want to change to.

Other Notes

The ChDir function changes only the current directory. Use this function in tandem with ChDrive function to change the current drive first.

Example usage

The ChDir statement can be used in VBA. Let’s look at some ChDir function examples:

ChDir "C:\Users\login\Desktop"
Result: Changes current directory to "C:\Users\login\Desktop"

ChDrive "C:\Program Files"
Result: Changes current directory to "C:\Program Files"