以语言独立的方式获得“我的文档”文件夹在VBA Excel 2003中 [英] Language independent way to get "My Documents" folder in VBA Excel 2003

查看:119
本文介绍了以语言独立的方式获得“我的文档”文件夹在VBA Excel 2003中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种独立于语言的方式在VBA Excel 2003中获取我的文档文件夹。



我有什么:

 公共函数MyDocsPath()As String 
MyDocsPath = Environ $(USERPROFILE)& \My Documents\
结束函数

因为程序将被用于至少有2个lang MS Windows,并且每个语言的我的文档名称都会更改。



有没有办法,或者我应该尝试找出系统lang和成为具体?

解决方案

这可能适合:

 设置WshShell = CreateObject(WScript.Shell)
strDocuments = WshShell.SpecialFolders(MyDocuments)

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



虽然特殊文件夹名称是MyDocuments,但它指的是Windows的多个版本的文档文件夹。


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?

解决方案

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.

这篇关于以语言独立的方式获得“我的文档”文件夹在VBA Excel 2003中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆