Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get current user folder in Windows XP? 2

Status
Not open for further replies.

Werneck

Technical User
Aug 5, 2003
36
0
0
BR
Hi

I need to export files to the My documents folder in Windows XP.

How to get the Windows user name to assemble the path string to its My documents folder (like the example bellow)?

C:\Documents and Settings\UserName\My documents

Thanks
 
Try this -

Dim strUser as String
Dim strpath as String

'Get Windows username
strUser = Environ("USERNAME")
'create string for path
strPath = "C:\Documents and Settings\" & strUser & "\My documents"

'do whatever with strPath

Good luck, CJ
 
Hi,

It is all to easy to map the my documents directory to be outside the user profile in most versions of Windows. Instead, I would read the Personal key from within the following registry section:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

John
 
Thanks, CJ and John, for the helpfull suggestions.
Cesar
 
Hi

How do I get the string of the following register section in Acc97 vba code? Is there a simple code like using the Environ()?

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top