Bonjour,
je souhaite surveiller plusieurs pings sur Excel. J'ai trouvé un auto fonctionnant sur windows mais je suis sur Mac OS.
Voici le liens de la video:
J'ai repris ce code:
Function Ping(strip)
Dim objshell, boolcode
Set objshell = CreateObject("Wscript.Shell")
boolcode = objshell.Run("ping -n 1 -w 1000 " & strip, 0, True)
If boolcode = 0 Then
Ping = True
Else
Ping = False
End If
End Function
Sub PingSystem()
Dim strip As String
Do Until ActiveSheet.Range("F1").Value = "STOP"
ActiveSheet.Range("F1").Value = "TESTING"
For introw = 2 To ActiveSheet.Cells(65536, 2).End(xlUp).Row
strip = ActiveSheet.Cells(introw, 2).Value
If Ping(strip) = True Then
ActiveSheet.Cells(introw, 3).Interior.ColorIndex = 0
ActiveSheet.Cells(introw, 3).Font.Color = RGB(0, 0, 0)
ActiveSheet.Cells(introw, 3).Value = "Online"
Application.Wait (Now + TimeValue("0:00:01"))
ActiveSheet.Cells(introw, 3).Font.Color = RGB(0, 200, 0)
Else
ActiveSheet.Cells(introw, 3).Interior.ColorIndex = 0
ActiveSheet.Cells(introw, 3).Font.Color = RGB(200, 0, 0)
ActiveSheet.Cells(introw, 3).Value = "Offline"
Application.Wait (Now + TimeValue("0:00:01"))
ActiveSheet.Cells(introw, 3).Interior.ColorIndex = 6
End If
If ActiveSheet.Range("F1").Value = "STOP" Then
Exit For
End If
Next
Loop
ActiveSheet.Range("F1").Value = "IDLE"
End Sub
Sub stop_ping()
ActiveSheet.Range("F1").Value = "STOP"
End Sub
La ligne : Set objshell = CreateObject("Wscript.Shell") est celle qui me pose problème pour le moment.
Merci pour votre aide.