programing

VBA Excel 2003에서 "내 문서" 폴더를 가져오는 언어 독립적인 방법

telebox 2023. 7. 6. 22:09
반응형

VBA Excel 2003에서 "내 문서" 폴더를 가져오는 언어 독립적인 방법

VBA Excel 2003에서 "내 문서" 폴더를 가져오려면 언어 독립적인 방법이 필요합니다.

내가 가진 것:

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

프로그램이 적어도 2개의 언어 MS Windows에서 사용되고 각 언어에 대해 "내 문서" 이름이 변경되기 때문입니다.

방법이 있습니까, 아니면 시스템 언어를 파악하여 구체적으로 설명해야 합니까?

적합할 수 있습니다.

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

보낸 사람: http://msdn.microsoft.com/en-us/library/0ea7b5xe.aspx

특수 폴더 이름은 MyDocuments이지만 여러 Windows 버전의 문서 폴더를 나타냅니다.

현지화된 버전이 동일한 위치를 가리키므로 "문서"를 사용할 수 있습니다.

' Application.PathSeparator can be used, but this
' is unlikely to work on non-Windows environments
MyDocsPath = Environ$("USERPROFILE") & "\Documents\"

(이 질문이 10년 전의 질문인 것을 보면 그때는 그렇지 않았을 수도 있습니다.:)

언급URL : https://stackoverflow.com/questions/7751464/language-independent-way-to-get-my-documents-folder-in-vba-excel-2003

반응형