Ping

G

Greg Glynn

Hi Guys,

This function returns the ping resolve time.

Function xlPing(strHost As String)
'Ping a host to see if it is alive
Dim objPing
Dim objRetStatus
Dim strMessage

If strHost = "" Then
xlPing = False
'MsgBox "No host defined", vbCritical, "Whoops"
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
xlPing = False
Else
xlPing = objRetStatus.ResponseTime
End If
Next
End If

Set objPing = Nothing
Set objRetStatus = Nothing
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top