Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Locating the My Documents Folder.

Locating the My Documents Folder

by Allen Wyatt
(last updated May 24, 2014)

1

When creating a macro, you may need to know the full path to the user's My Documents folder. The path can differ, based on the system and the user logged into the system. The easiest way to locate it is through the use of the Environ function, as shown here:

MsgBox Environ("userprofile") & "\My Documents"

This code line displays the full path (including the drive letter) in a message box. If you want to have the path assigned to a string variable instead, you can use this code line:

sMyPath = Environ("userprofile") & "\My Documents"

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13115) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Locating the My Documents Folder.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Error Generated if Files Opened in Word Session

Greg has a problem with Word 2002 crashing, depending on how he opens files. This seems to be a problem that Microsoft knows ...

Discover More

Word Styles and Templates (Special Offer)

Discovering how to use styles can really boost your proficiency with Word. Another way you can increase your proficiency is ...

Discover More

Default Worksheet when Opening

When opening a workbook, you may want to make sure that a particular worksheet is always displayed first. The only way to ...

Discover More

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!

More WordTips (ribbon)

Determining the Hour of the Day

Need to figure out the hour represented by a particular time value? It's easy to do in a macro; just use the Hour function, ...

Discover More

Highlighting Every Thousandth Character

Not satisfied with the detail provided by the Word Count feature in Word? Perhaps you want to actually know where every one ...

Discover More

Repaginating in a Macro

When creating a macro that extensively processes a document, you may need to periodically force Word to repaginate the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight minus 2?

2014-05-24 08:19:19

PeterJ

Hi Allen

I've been using this method on PCs running Windows successfully for quite a long time. Unfortunately, the Environ function does not work on MACs. Does anyone know an equally easy solution to finding the MAC equivalent of the 'My Documents' folder?

Thanks
Peter


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.