Function IPAddress() 'Thanks to Scriptomatic for the starting point! Dim strComputer, objWMIService, colItems, objItem, strQuery, strIP strComputer = "." strQuery = "Select IPAddress from Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery(strQuery,,48) '''''''''''''''''''''' ' Here's another way of getting the colItems collection: ' Set wbem = CreateObject("WbemScripting.SWbemLocator").ConnectServer ' Set colItems = wbem.ExecQuery(strQuery) '''''''''''''''''''''' For Each objItem in colItems If Not IsNull(objItem.IPAddress) Then strIP = objItem.IPAddress(0) 'always the first element Exit For 'Leave this to get first address, drop to get last. End If Next IPAddress = strIP End Function