excelvbaexcel-2003

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


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?


Solution

  • 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.