VBA: ChDir function

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

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"

Simply the best place to learn VBA!

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match