Results 1 to 6 of 6

Thread: Check port is up from VBA (Excel)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Regular Apps's Avatar
    Joined
    May 2006
    Posts
    38
    Location
    Sub TestPing()
        Dim strComputer As String
        strComputer = "<TargetComputerAddress>"
        If Not SystemOnline(strComputer) Then
            MsgBox "This computer is currently unreachable: " & strComputer, vbOKOnly, "Computer Status"
            '....your logic
        Else
            '...your logic
            MsgBox "This computer is Online!", vbOKOnly, "Computer Status"
        End If
    End Sub 
    
    'TestPing
    'Determine if system is online
    Function SystemOnline(ByVal ComputerName As String)
        Dim oShell, oExec As Variant
        Dim strText, strCmd As String
        strText = ""
        strCmd = "ping -n 3 -w 1000 " & ComputerName
        Set oShell = CreateObject("WScript.Shell")
        Set oExec = oShell.Exec(strCmd)
        Do While Not oExec.StdOut.AtEndOfStream
            strText = oExec.StdOut.ReadLine()
            If InStr(strText, "Reply") > 0 Then
                SystemOnline = True
                Exit Do
            End If
        Loop
    End Function
    originally from here :
    http://forums.devshed.com/visual-bas...ba-328706.html

    Tested and working on my system and worked ok if it's any good to you?
    Last edited by Aussiebear; 12-07-2024 at 02:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •