I have found a module to retrieve the system IP adress of a machine, but on some systems (so far only 3 out of 35) it fails on line 3 of the code:
The error reported is error 91 - Object variable or with object variable not set.
What do I need to add to make this work on all machines?
Code:
Public Function getMyIP()
Dim myWMI As Object, myobj As Object, itm
Set myWMI = GetObject("winmgmts:\\.\root\cimv2")
Set myobj = myWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each itm In myobj
getMyIP = itm.IPAddress(0)
Exit Function
Next
End Function
The error reported is error 91 - Object variable or with object variable not set.
What do I need to add to make this work on all machines?