MS Excel: ChDir Statement (VBA only)
In Excel, the ChDir statement allows you to change the current directory or folder.
The syntax for the ChDir function is:
ChDir path
path is the path that you'd like to set the current directory to.
Note:
The ChDir lets you change the current directory on the current drive. If you need to change drives, try using the ChDrive statement first.
Applies To:
- Excel 2007, Excel 2003, Excel XP, Excel 2000
For example:
ChDir "C:\instructions" would set the current directory to C:\instructions ChDir "C:\Documents\Supplies" would set the current directory to C:\Documents\Supplies
VBA Code
The ChDir statement can be used in VBA code. For example:
ChDir "C:\instructions"
In this example, the current directory would now be changed to C:\instructions.