Language independent way to get "My Documents" folder in VBA Excel 2003

Diego Castro picture Diego Castro · Oct 13, 2011 · Viewed 15.5k times · Source

I need a Language independent way to get "My Documents" folder in VBA Excel 2003.

What I have:

Public Function MyDocsPath() As String
    MyDocsPath = Environ$("USERPROFILE") & "\My Documents\"
End Function

Because the program will be used in at least 2 lang MS Windows, and the "My Documents" name changes for each language.

Is there a way, or should I try to figure out the system lang and become specific?

Answer

Fionnuala picture Fionnuala · Oct 13, 2011

This may suit:

Set WshShell = CreateObject("WScript.Shell")
strDocuments = WshShell.SpecialFolders("MyDocuments")

From: http://msdn.microsoft.com/en-us/library/0ea7b5xe.aspx

Although the special folder name is MyDocuments, it refers to the documents folder for several versions of Windows.