
Tips.Net > WordTips Home > Macros > Creating Macros > Locating the My Documents Folder
Summary: Your macro, in the process of working with user files, may need to figure out where the My Documents folder is actually located. Once you understand how to access the user profile information, the desired path is a snap to recover. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
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"
Tip #222 applies to Microsoft Word versions: 97 2000 2002 2003
Great Idea! Word is a tool to get what you really want—printed output. This means you need to make sure that Word works as well as possible with your printer, whether it is sitting on your desk or in a room down the hall.
Check out WordTips: Printing and Printers today!
It doesn't matter if you are a beginner or expert, the WordTips archives are the fastest way to improved productivity. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips