Smitty,
Sorry fo rmy delay, below is the API function i was trying to use - basically, I have a list of IPs in column A, I would like to launch a marcro to ping each IP down the various rows and return a value in the adjacent cell in column B (red or green, or Up/down, etc...) at the very bottom of this post is a bit of code i use to ping an IP from a single cell, but it doesnt move on to the next nor provide any result in column B.
Option ExplicitPrivate Declare Function IcmpCreateFile Lib "icmp.dll" () As LongPrivate Declare Function inet_addr Lib "WSOCK32.DLL" (ByVal cp As String) As LongPrivate Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal IcmpHandle As Long) As LongPrivate Declare Function IcmpSendEcho Lib "icmp.dll" _ (ByVal IcmpHandle As Long, _ ByVal DestinationAddress As Long, _ ByVal RequestData As String, _ ByVal RequestSize As Long, _ ByVal RequestOptions As Long, _ ReplyBuffer As ICMP_ECHO_REPLY, _ ByVal ReplySize As Long, _ ByVal timeout As Long) As Long Private Type IP_OPTION_INFORMATION Ttl As Byte Tos As Byte Flags As Byte OptionsSize As Byte OptionsData As LongEnd Type Public Type ICMP_ECHO_REPLY address As Long Status As Long RoundTripTime As Long DataSize As Long Reserved As Integer ptrData As Long Options As IP_OPTION_INFORMATION data As String * 250End TypePublic Function ping(strAddress As String, Reply As ICMP_ECHO_REPLY) As BooleanDim hIcmp As LongDim lngAddress As LongDim lngTimeOut As LongDim strSendText As String'Short string of data to sendstrSendText = "blah"' timeout value in mslngTimeOut = 1000'Convert string address to a longlngAddress = inet_addr(strAddress)If (lngAddress <> -1) And (lngAddress <> 0) Then hIcmp = IcmpCreateFile() If hIcmp <> 0 Then 'Ping the destination IP Call IcmpSendEcho(hIcmp, lngAddress, strSendText, Len(strSendText), 0, Reply, Len(Reply), lngTimeOut) 'Reply status ping = (Reply.Status = 0) 'Close the Icmp handle. IcmpCloseHandle hIcmp Else ping = False End IfElse ping = FalseEnd IfEnd FunctionSub TestPinger() Dim blnResponse As Boolean, lngStatus As ICMP_ECHO_REPLY blnResponse = ping("10.100.1.1", lngStatus) Debug.Print blnResponseEnd Sub</PRE>
Ping IP from Cell
Option ExplicitPrivate Declare Function IcmpCreateFile Lib "icmp.dll" () As LongPrivate Declare Function inet_addr Lib "WSOCK32.DLL" (ByVal cp As String) As LongPrivate Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal IcmpHandle As Long) As LongPrivate Declare Function IcmpSendEcho Lib "icmp.dll" _ (ByVal IcmpHandle As Long, _ ByVal DestinationAddress As Long, _ ByVal RequestData As String, _ ByVal RequestSize As Long, _ ByVal RequestOptions As Long, _ ReplyBuffer As ICMP_ECHO_REPLY, _ ByVal ReplySize As Long, _ ByVal timeout As Long) As Long Private Type IP_OPTION_INFORMATION Ttl As Byte Tos As Byte Flags As Byte OptionsSize As Byte OptionsData As LongEnd Type Public Type ICMP_ECHO_REPLY address As Long Status As Long RoundTripTime As Long DataSize As Long Reserved As Integer ptrData As Long Options As IP_OPTION_INFORMATION data As String * 250End TypePublic Function ping(strAddress As String, Reply As ICMP_ECHO_REPLY) As BooleanDim hIcmp As LongDim lngAddress As LongDim lngTimeOut As LongDim strSendText As String'Short string of data to sendstrSendText = "blah"' timeout value in mslngTimeOut = 1000'Convert string address to a longlngAddress = inet_addr(strAddress)If (lngAddress <> -1) And (lngAddress <> 0) Then hIcmp = IcmpCreateFile() If hIcmp <> 0 Then 'Ping the destination IP Call IcmpSendEcho(hIcmp, lngAddress, strSendText, Len(strSendText), 0, Reply, Len(Reply), lngTimeOut) 'Reply status ping = (Reply.Status = 0) 'Close the Icmp handle. IcmpCloseHandle hIcmp Else ping = False End IfElse ping = FalseEnd IfEnd FunctionSub TestPinger() Dim blnResponse As Boolean, lngStatus As ICMP_ECHO_REPLY blnResponse = ping("10.100.1.1", lngStatus) Debug.Print blnResponseEnd Sub</PRE>