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
>
>
|