LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Attempting to use VBA to Ping within Excel...

"Andy Dawkins" wrote:

Thank you urkec for your responce. I noticed that you mentioned that
Win32_PingStatus was added for windows XP. If I'm using Windows 2000 what
would I need to do to make it work?



I found that code he

http://www.rlmueller.net/PingComputers.htm

You can find other two samples there, one uses WScript.Shell Exec method to
execute the Ping command and then checks it's output to determine if ping was
successful. The other uses WScript.Shell Run method. Both will work with
Windows 2000 (the first sample requires Windows Script Host 5.6, the other
WSH 5.1) If you use WshShell.Exec you won't be able to prevent Command Prompt
appearing on the screen, if you use WshShell.Run you will have to write the
Ping command output to a temporary txt file, so those are not ideal
solutions. The samples are VBScript, VBA the code would look something like
this:


Function Ping2(ByVal Host As String, _
ByVal Pings As Integer, ByVal TimeOut As Integer) As Boolean

Status = CreateObject("WScript.Shell"). _
Exec("%comspec% /c Ping -n " & CStr(Pings) & _
" -w " & CStr(TimeOut) & " " & Host).StdOut.ReadAll

'Debug.Print Status

If InStr(Status, "TTL=") = 0 Then
Ping2 = False
Else
Ping2 = True
End If

End Function


Then you can call Ping2 like this:


Ping2("ANAME", 1, 750)



--
urkec
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ping from Excel - Almost there RRohl Excel Programming 3 August 22nd 06 07:26 AM
PING within Excel Cell Steve Excel Worksheet Functions 1 July 14th 06 02:58 PM
Excel Ping Command..via web... HickoryShade[_4_] Excel Programming 6 December 13th 05 03:30 PM
Ping results into Excel RB Smissaert Excel Programming 0 February 24th 05 03:00 PM
ping in excel Andy Mohan Excel Programming 5 February 21st 05 10:08 PM


All times are GMT +1. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"