PC Review


Reply
Thread Tools Rate Thread

Check if i'm connected to the internet

 
 
=?Utf-8?B?Sm9obg==?=
Guest
Posts: n/a
 
      11th Jun 2007
Hi,

Is it possible in XL to check if i'm connected to the internet?

Thanks

John

 
Reply With Quote
 
 
 
 
Leith Ross
Guest
Posts: n/a
 
      11th Jun 2007

John wrote:
> Hi,
>
> Is it possible in XL to check if i'm connected to the internet?
>
> Thanks
>
> John


You will need to the Wiindows API to determine if your connection is
live, not just that you have a
physical connection to the internet. Place this code in a Standard VBA
Module. The Function portions test if your connection is live, and the
Sub will display the results with a MessageBox.

'Note: WinINet dial-up functions do not support double-dial
connections,
'SmartCard authentication, or connections that require registry-based
certification.

'Flags for GetInternetState, these are returned
Public Const INTERNET_CONNECTION_MODEM As Long = &H1
Public Const INTERNET_CONNECTION_LAN As Long = &H2
Public Const INTERNET_CONNECTION_PROXY As Long = &H4
Public Const INTERNET_CONNECTION_MODEM_BUSY As Long = &H8
Public Const INTERNET_RAS_INSTALLED As Long = &H10
Public Const INTERNET_CONNECTION_OFFLINE As Long = &H20
Public Const INTERNET_CONNECTION_CONFIGURED As Long = &H40

Public Declare Function GetInternetState _
Lib "Wininet.dll" _
Alias "InternetGetConnectedState" _
(ByVal lpdwFlags As Long, _
ByVal Reserved As Long) As Long


Public Function IsInternetLive() As Boolean

Dim Flags As Long
Dim Ret

Ret = GetInternetState(Flags, 0&)
IsInternetLive = Ret And Not (Flags And
INTERNET_CONNECTION_OFFLINE)

End Function

Sub CheckInternetConnection()

If IsInternetLive Then
MsgBox "You are connected to the Internet."
Else
MsgBox "You are not connected to the Internet."
End If

End Sub

Sincerely,
Leith Ross

 
Reply With Quote
 
=?Utf-8?B?Sm9obg==?=
Guest
Posts: n/a
 
      11th Jun 2007
Thanks Leith, perfect solution

John

"Leith Ross" wrote:

>
> John wrote:
> > Hi,
> >
> > Is it possible in XL to check if i'm connected to the internet?
> >
> > Thanks
> >
> > John

>
> You will need to the Wiindows API to determine if your connection is
> live, not just that you have a
> physical connection to the internet. Place this code in a Standard VBA
> Module. The Function portions test if your connection is live, and the
> Sub will display the results with a MessageBox.
>
> 'Note: WinINet dial-up functions do not support double-dial
> connections,
> 'SmartCard authentication, or connections that require registry-based
> certification.
>
> 'Flags for GetInternetState, these are returned
> Public Const INTERNET_CONNECTION_MODEM As Long = &H1
> Public Const INTERNET_CONNECTION_LAN As Long = &H2
> Public Const INTERNET_CONNECTION_PROXY As Long = &H4
> Public Const INTERNET_CONNECTION_MODEM_BUSY As Long = &H8
> Public Const INTERNET_RAS_INSTALLED As Long = &H10
> Public Const INTERNET_CONNECTION_OFFLINE As Long = &H20
> Public Const INTERNET_CONNECTION_CONFIGURED As Long = &H40
>
> Public Declare Function GetInternetState _
> Lib "Wininet.dll" _
> Alias "InternetGetConnectedState" _
> (ByVal lpdwFlags As Long, _
> ByVal Reserved As Long) As Long
>
>
> Public Function IsInternetLive() As Boolean
>
> Dim Flags As Long
> Dim Ret
>
> Ret = GetInternetState(Flags, 0&)
> IsInternetLive = Ret And Not (Flags And
> INTERNET_CONNECTION_OFFLINE)
>
> End Function
>
> Sub CheckInternetConnection()
>
> If IsInternetLive Then
> MsgBox "You are connected to the Internet."
> Else
> MsgBox "You are not connected to the Internet."
> End If
>
> End Sub
>
> Sincerely,
> Leith Ross
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      12th Jun 2007
Whilst there is a range of API function to tell you various info about
state, if you need to cater for all the possible ways users may connect, the
only reliable way is try a known site.
How you do that is up to you: Ping, HTTPRequest, WebQuery etc.

NickHK

"John" <(E-Mail Removed)> wrote in message
news:42A021B7-5B1F-41E2-B43A-(E-Mail Removed)...
> Hi,
>
> Is it possible in XL to check if i'm connected to the internet?
>
> Thanks
>
> John
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista says I'm not connected to the Internet while I am connected HotmailUser Windows Vista Networking 0 18th May 2008 12:57 AM
How to check if my PocketPC is connected to the internet (with C#). balajis Microsoft Dot NET Compact Framework 1 6th May 2004 10:57 AM
How to check if my PocketPC is connected to the internet (with C#). balajis Microsoft Dot NET Compact Framework 0 29th Apr 2004 09:10 PM
how to check if internet is connected? Paul M Microsoft Dot NET Framework Forms 0 2nd Apr 2004 04:19 PM
How to check if user is online (connected to internet)? Martin Ho Microsoft VB .NET 3 28th Dec 2003 10:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:29 AM.