Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining the Current Directory.
by Allen Wyatt
(last updated July 2, 2018)
If you are programming macros in VBA, it is often helpful to know the directory that Windows feels is the current one. You can find out which directory is current by using the following syntax:
MyDir = CurDir
When this line is executed, MyDir (a string) will be equal to the full path of the current directory.
Understand that the path returned by CurDir is the path that Windows feels is the current directory, not the path that Excel feels is the current directory. In other words, CurDir won't return a path equal to the current path in which you are working with your workbooks. CurDir reflects the directory set using the ChDir command, which is detailed in a different ExcelTip.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9363) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Determining the Current Directory.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Unprotecting a single worksheet is relatively easy. Unprotecting a whole lot of worksheets is harder. Here's how you can ...Discover More
Normally Excel positions a UserForm in the center of your screen. You may want to position the form elsewhere, more ...Discover More
The security features built into Excel allow you to digitally sign your macros so that users can rest assured that they ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.