A few ways:
1)
'Standard Module code, like: Module1!
Public Declare Function InternetGetConnectedState _
Lib "wininet.dll" (lpdwFlags As Long, _
ByVal dwReserved As Long) As Boolean
Function IEAvailable() As Boolean
'Standard Module code, like: Module1!
Dim IEStat As Long
IEAvailable = (InternetGetConnectedState(IEStat, 0&) <> 0)
End Function
Sub isInternetAvailable()
'Standard Module code, like: Module1!
If IEAvailable = False Then MsgBox "No, Internet connection is available, at this time!"
If IEAvailable = True Then MsgBox "An Internet connection is available, at this time!"
End Sub
2)
Sub IEOpen()
'Open Internet Explorer as a new window!
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
'ie.Visible = True
With ie
'Open Internet Explorer Window!
.Visible = True
'Optional: Open with this web-page!
.Navigate "http://infonetWebSpace"
End With
Set ie = Nothing
End Sub
Sub IEOpen2()
'Open, do not make active window
Shell "C:\Program Files\Internet Explorer\iexplore.exe http://infonetWebSpace"
End Sub
3)
Private Declare Function InternetGetConnectedStateEx _
Lib "wininet.dll" ( _
ByRef lpdwFlags As Long, _
ByVal lpszConnectionName As String, _
ByVal dwNameLen As Integer, _
ByVal dwReserved As Long) _
As Long
Private Declare Function InternetCheckConnection _
Lib "wininet.dll" _
Alias "InternetCheckConnectionA" ( _
ByVal lpszUrl As String, _
ByVal dwFlags As Long, _
ByVal dwReserved As Long) _
As Long
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
'// Reference this msg!
'Private Const strSite As String = _
' "http://www.mrexcel.com/board2/viewtopic.php?t=157314&postdays=0&postorder=asc&start=10"
Private Const strSite As String = "http://www.mrexcel.com/board2"
Dim strISPName As String * 255
Sub CheckConnection()
Dim Ret As Long
Ret = InternetGetConnectedStateEx(Ret, strISPName, 254, 0)
If InternetCheckConnection(strSite, FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "You are NOT connected", vbInformation
Else
MsgBox "You ARE connected to " & strSite & vbCrLf & "Via: " & strISPName, vbInformation
End If
End Sub