我需要一种独立于语言的方式来获得“我的文档”文件夹在VBA Excel2003。
我所拥有的:
Public Function MyDocsPath() As String
MyDocsPath = Environ$("USERPROFILE") & "\My Documents\"
End Function
因为该程序将在至少2个lang MS Windows中使用,并且“我的文档”名称随每种语言的变化而变化。
有没有办法,或者我应该试着找出系统语言并变得具体?
发布于 2011-10-13 08:56:19
这可能适合:
Set WshShell = CreateObject("WScript.Shell")
strDocuments = WshShell.SpecialFolders("MyDocuments")
来自:http://msdn.microsoft.com/en-us/library/0ea7b5xe.aspx
尽管特殊文件夹名是MyDocuments,但它指的是多个版本的Windows文件夹。
发布于 2021-05-05 08:28:07
您可以使用“文档”,因为本地化版本指向相同的位置。
' Application.PathSeparator can be used, but this
' is unlikely to work on non-Windows environments
MyDocsPath = Environ$("USERPROFILE") & "\Documents\"
(考虑到这是一个10年前的问题,当时可能不是这样的。:)
https://stackoverflow.com/questions/7751464
复制相似问题