VBA 的环境函数代码示例 [英] Environ Function code samples for VBA
本文介绍了VBA 的环境函数代码示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一些信息或代码示例,用于 VBA 中的 Environ
函数以获取当前系统上的用户名.
I am looking for some information or code samples for the Environ
Function in VBA to grab the username on the current system.
推荐答案
Environ()
获取任何环境变量的值.这些可以通过在命令提示符中执行以下命令来找到:
Environ()
gets you the value of any environment variable. These can be found by doing the following command in the Command Prompt:
set
如果你想获得用户名,你会这样做:
If you wanted to get the username, you would do:
Environ("username")
如果您想获得完全限定的名称,您可以:
If you wanted to get the fully qualified name, you would do:
Environ("userdomain") & "" & Environ("username")
参考文献
查看全文