Excel VBA如何取得计算机已登录的域名称

如题所述

environ("userdomain")

这是最简单的方法。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-07-03
可以.如下
Public Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim i As Integer

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each IP In colIP
If Not IsNull(IP.IPAddress) Then
For i = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox IP.IPAddress(i), vbInformation, IP.Description(i)
Next
End If
Next
MsgBox "Excel版本信息为:" & Application.CalculationVersion
MsgBox "Excel当前允许使用的内存为:" & Application.MemoryFree
MsgBox "Excel当前已使用的内存为:" & Application.MemoryUsed
MsgBox "Excel可以使用的内存为:" & Application.MemoryTotal
MsgBox "本机操作系统的名称和版本为:" & Application.OperatingSystem
MsgBox "本产品所登记的组织名为:" & Application.OrganizationName
MsgBox "当前用户名为:" & Application.UserName
MsgBox "当前使用的Excel版本为:" & Application.Version
End Sub本回答被网友采纳
相似回答