VBA 的环境函数代码示例 [英] Environ Function code samples for VBA

查看:17
本文介绍了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")

参考文献

  • 微软 |Office VBA 参考 |语言参考 VBA |环境函数
  • 微软 |办公支持 |环境功能
  • 这篇关于VBA 的环境函数代码示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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