/* https://stackoverflow.com/a/949986/3599237 */ Function GetIPAddress() Const strComputer As String = "." ' Computer name. Dot means local computer Dim objWMIService, IPConfigSet, IPConfig, IPAddress, i Dim strIPAddress As String ' Connect to the WMI service Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") ' Get all TCP/IP-enabled network adapters Set IPConfigSet = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE") ' Get all IP addresses associated with these adapters For Each IPConfig In IPConfigSet IPAddress = IPConfig.IPAddress If Not IsNull(IPAddress) Then strIPAddress = strIPAddress & Join(IPAddress, ", ") End If Next GetIPAddress = strIPAddress End Function