Function GetIP() As String Dim OpSysSet As Object, Op As Object, Ip Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost").ExecQuery("SELECT index, IPAddress FROM Win32_NetworkAdapterConfiguration") For Each Op In OpSysSet If Not IsNull(Op.IPAddress) Then For Each Ip In Op.IPAddress If Ip Like "*.*.*.*" Then GetIP = Ip Exit Function End If Next End If Next End Function