G
Greg Glynn
Hi People,
This function returns the IP Address of a known host. I hope you find
it useful.
Function xlGetIPAddress(strHost As String)
'Ping a host to see if it is alive
Dim objPing
Dim objRetStatus
Dim strMessage
If strHost = "" Then
xlGetIPAddress = False
Else
Set objPing = GetObject("winmgmts:
{impersonationLevel=impersonate}").ExecQuery("select * from
Win32_PingStatus where address = '" & strHost & "'")
For Each objRetStatus In objPing
If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <>
0 Then
xlGetIPAddress = False
Else
xlGetIPAddress = objRetStatus.ProtocolAddress
End If
Next
End If
Set objPing = Nothing
Set objRetStatus = Nothing
End Function
This function returns the IP Address of a known host. I hope you find
it useful.
Function xlGetIPAddress(strHost As String)
'Ping a host to see if it is alive
Dim objPing
Dim objRetStatus
Dim strMessage
If strHost = "" Then
xlGetIPAddress = False
Else
Set objPing = GetObject("winmgmts:
{impersonationLevel=impersonate}").ExecQuery("select * from
Win32_PingStatus where address = '" & strHost & "'")
For Each objRetStatus In objPing
If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <>
0 Then
xlGetIPAddress = False
Else
xlGetIPAddress = objRetStatus.ProtocolAddress
End If
Next
End If
Set objPing = Nothing
Set objRetStatus = Nothing
End Function