View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] adimax@gmail.com is offline
external usenet poster
 
Posts: 8
Default Returning the IP results from a ping?

I snagged this beautiful piece of code from here, and I've seen other
code that could do it, but I'm having a hard time gluing it all
together. Is there any way I can make this:

---start code---

Public Sub PingIt()

Set Machines = Sheets(1).Range("A1", "A3")

For Each Machine In Machines.Cells
Debug.Print Machine
Set objPing = GetObject _
("winmgmts:{impersonationLevel=impersonate}"). _
ExecQuery("select * from Win32_PingStatus " & _
"where address = '" & Machine & "'")

For Each objStatus In objPing

If objStatus.StatusCode = 0 Then
Sheets(1).Cells(Machine.Row, Machine.Column + 1) = _
"Success"


Else

Sheets(1).Cells(Machine.Row, Machine.Column + 1) = _
"Failed"

End If

Next
Next

End Sub

---end code---

Not only tell me if it Success/Failed on the ping, but also in the
next column over the IP address?

TIA,
Benjamin