Ping domains / Host

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Excel sheet (2007) with thousands of domain in one column and is
there anyway to get the next column saying that the perticular domain is
pinging or not?
 
Try this.

Tim


'********************************************************
Sub Tester()
Debug.Print GoodDomain("www.google.com")
End Sub


Function GoodDomain(sdomain As String) As Boolean
Dim oShell As Object
Dim v

Set oShell = CreateObject("WScript.Shell")
Set v = oShell.Exec("ping " & sdomain & " -n 1")
GoodDomain = Not InStr(v.StdOut.ReadAll, "could not find host") > 0

End Function
'********************************************************
 
What did you do ?
The function needs to be in a genral module, not in the sheet module...

Tim
 
Try this instead.
Tim

Option Explicit

Sub TestDomains()

Dim c As Range
Dim oShell As Object
Dim v

Set oShell = CreateObject("WScript.Shell")

For Each c In Selection.Cells
If c.Value <> "" Then
Set v = oShell.Exec("ping " & c.Value & " -n 1")
If InStr(v.StdOut.ReadAll, "could not find host") <> 0 Then
c.Offset(0, 1).Value = "Problem"
Else
c.Offset(0, 1).Value = "OK"
End If
End If
Next c

End Sub
 
Hey thanks Tim got the required output.... Can this made as the background
process as all most 1000 command windows are openning for the Excel i have?

Ganesh
 
Back
Top