Bright01
asked on
Checking for Internet Connection
EE Pros,
I have a Macro that updates MSN Currency when fired.
Is there a way to check to see that a connection exists and if not, notify the user that "No Internet Connection Detected".
Sub CurrencyUpdate()
Sheets("Currency").QueryTa bles(1).Re fresh
End Sub
That's it!
Thank you in advance,
B.
I have a Macro that updates MSN Currency when fired.
Is there a way to check to see that a connection exists and if not, notify the user that "No Internet Connection Detected".
Sub CurrencyUpdate()
Sheets("Currency").QueryTa
End Sub
That's it!
Thank you in advance,
B.
You can use something like the following code:
Which in short says "If internet is active then refresh data, else notify user..."
Which in short says "If internet is active then refresh data, else notify user..."
Private Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef dwflags As Long, _
ByVal dwReserved As Long) As Long
Private Const INTERNET_CONNECTION_MODEM As Long = &H1
Private Const INTERNET_CONNECTION_LAN As Long = &H2
Private Const INTERNET_CONNECTION_PROXY As Long = &H4
Private Const INTERNET_CONNECTION_OFFLINE As Long = &H20
Function IsInternetConnected() As Boolean
Dim L As Long
Dim R As Long
R = InternetGetConnectedState(L, 0&)
If R = 0 Then
IsInternetConnected = False
Else
If R <= 4 Then
IsInternetConnected = True
Else
IsInternetConnected = False
End If
End If
End Function
Sub CurrencyUpdate()
If IsInternetConnected() = True Then
Sheets("Currency").QueryTables(1).Refresh
Else
MsgBox "No internet connection is detected!"
End If
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rgonzo and ThinkSpace,
Where do I put this code? In the WS or a Module?
B.
Where do I put this code? In the WS or a Module?
B.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you! Both solutions work...... good teamwork guys.
B.
B.
http://www.mrexcel.com/forum/excel-questions/567315-check-if-url-exists-so-then-return-true.html