Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Check if i'm connected to the internet

Hi,

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

Thanks

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Check if i'm connected to the internet


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Check if i'm connected to the internet

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Check if i'm connected to the internet

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" wrote in message
...
Hi,

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

Thanks

John



Reply
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
Averaging cells not connected Gary New Users to Excel 3 October 19th 08 05:21 PM
hangs when connected Gerhard Adendorff Excel Discussion (Misc queries) 0 April 13th 07 06:56 AM
how to do a "check for updates" over the internet [email protected] Excel Programming 2 February 17th 07 08:41 PM
Check for instance of Internet Explorer BBert Excel Programming 1 January 26th 07 08:06 PM
How to check for Internet connection Vikram[_4_] Excel Programming 3 June 16th 06 10:55 AM


All times are GMT +1. The time now is 11:52 PM.

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"