How to fing ping via VBA?

  • Thread starter Thread starter hanski
  • Start date Start date
H

hanski

hi

I would like to know in my code if a certain computer is on or off and
continue then forward depending on the answer.

How it is possible to find out if the computer is online or offline
via VBA?

hanski
 
m:
How it is possible to find out if the computer is online or
offline via VBA?

You can check to see if a known named resource is available. If you
know the computer name and a share that has files in it, you could
check:

Dir("\\ComputerName\ShareName\*.*")

....if that doesn't error out, you know it's there and accessible. Of
course, if it's not, throws an error, and then you have to
distinguish which particular errors.

You could also use the File System Object, something like this:

Dim objFSO as Object

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileName) Then
Debug.Print strFileName & " exits."
End If

I pulled that from code I already have that's more complicated. It
has the advantage of not causing an error if the remote machine is
not accessible. It does take longer when the machine is inaccessible
than when it's not, but that should be OK.
 
Back
Top