VBA ChDir function

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

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.


The syntax for the ChDir function is:

ChDir( 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"

Simply the best place to learn VBA!