PING TEST FROM VB MACRO IN EXCEL

dgr

Board Regular
Joined
Apr 24, 2005
Messages
176
Hi,
I'd like my VB Macro in Excel to detect whether there is an active internet connection or not. If there is, I'd like the macro to do something & if there isn't, I'd like the macro to do something else.

Now, I've figured out the first part(I hope) which goes like this :-
ReturnValue = Shell("C:\WINDOWS\system32\ping.exe ""www.tm.net.my""", 1)

I don't know how to do the second part which should look something like this :-
If (ping test is successful) Then (do something) Else (do something else)

Could you please help me on this matter?

ROBERT RAM
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi, welcome to the board. This is from www.allapi.net

Rich (BB code):
Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal dwReserved As Long) As Long
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    If InternetAttemptConnect(ByVal 0&) = 0 Then
        MsgBox "You can connect to the Internet", vbInformation
    Else
        MsgBox "You cannot connect to the Internet", vbInformation
    End If
End Sub
 
Upvote 0
Thank you Juan,
This script constantly shows "You can connect to the Internet" regardless of whether I'm connected or not. I suspect that it's catered to work on dial-up. I'm using an ADSL modem. Is there a difference?

Warm Regards
ROBERT RAM
 
Upvote 0
Not sure... try this then (found on the same site)

Rich (BB code):
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
    'KPD-Team 2001
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    If InternetCheckConnection("http://www.allapi.net/", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
        MsgBox "Connection to http://www.allapi.net/ failed!", vbInformation
    Else
        MsgBox "Connection to http://www.allapi.net/ succeeded!", vbInformation
    End If
End Sub
 
Upvote 0
This code is excellent :) It works well. Thanks a lot for your help, Juan.

Warm Regards
ROBERT RAM
 
Upvote 0
Hi
thanks for the codes.I also tried this codes it really works well.But later my friend suggested that sites available for ping test are much more easier to perform a test than codes.After that i periodically perform ping test in http://www.whoisxy.com/ping.aspx .Its really simple.
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,101
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top