Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to check for Internet connection

I am developing an add-in which uses web query to update script prices
from the website.
As an error handling routine, I want to make sure that no error is
flashed by excel if someone tries to update price when there is no
internet connection available.

So can anyone suggest me how I can do this?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How to check for Internet connection


Vikram, try following:

Note: The API function gives a bit more information, but I've only used
the essenstial "Offline/online flag INTERNET_CONNECTION_OFFLINE = &H20&

Option Explicit

Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll"
Alias _
"InternetGetConnectedStateExA" (ByRef lpdwFlags As Long, ByVal _
lpszConnectionName As String, ByVal dwNameLen As Long, ByVal
dwReserved As _
Long) As Long

Function IsOnLine() As Boolean
Dim lFlag As Long
Dim sName As String
sName = Space(1)
If InternetGetConnectedStateEx(lFlag, sName, 0&, 0&) Then
IsOnLine = Not (lFlag And &H20)
End If

End Function

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Vikram wrote in
groups.com

I am developing an add-in which uses web query to update script prices
from the website.
As an error handling routine, I want to make sure that no error is
flashed by excel if someone tries to update price when there is no
internet connection available.

So can anyone suggest me how I can do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to check for Internet connection

Thanks a lot. It worked!!!!

keepITcool wrote:
Vikram, try following:

Note: The API function gives a bit more information, but I've only used
the essenstial "Offline/online flag INTERNET_CONNECTION_OFFLINE = &H20&

Option Explicit

Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll"
Alias _
"InternetGetConnectedStateExA" (ByRef lpdwFlags As Long, ByVal _
lpszConnectionName As String, ByVal dwNameLen As Long, ByVal
dwReserved As _
Long) As Long

Function IsOnLine() As Boolean
Dim lFlag As Long
Dim sName As String
sName = Space(1)
If InternetGetConnectedStateEx(lFlag, sName, 0&, 0&) Then
IsOnLine = Not (lFlag And &H20)
End If

End Function

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Vikram wrote in
groups.com

I am developing an add-in which uses web query to update script prices
from the website.
As an error handling routine, I want to make sure that no error is
flashed by excel if someone tries to update price when there is no
internet connection available.

So can anyone suggest me how I can do this?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to check for Internet connection

Thanks a lot. It worked!!!!

keepITcool wrote:
Vikram, try following:

Note: The API function gives a bit more information, but I've only used
the essenstial "Offline/online flag INTERNET_CONNECTION_OFFLINE = &H20&

Option Explicit

Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll"
Alias _
"InternetGetConnectedStateExA" (ByRef lpdwFlags As Long, ByVal _
lpszConnectionName As String, ByVal dwNameLen As Long, ByVal
dwReserved As _
Long) As Long

Function IsOnLine() As Boolean
Dim lFlag As Long
Dim sName As String
sName = Space(1)
If InternetGetConnectedStateEx(lFlag, sName, 0&, 0&) Then
IsOnLine = Not (lFlag And &H20)
End If

End Function

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Vikram wrote in
groups.com

I am developing an add-in which uses web query to update script prices
from the website.
As an error handling routine, I want to make sure that no error is
flashed by excel if someone tries to update price when there is no
internet connection available.

So can anyone suggest me how I can do this?


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
Internet connection stuenov Excel Discussion (Misc queries) 0 February 22nd 09 07:25 PM
Internet connection stuenov Excel Discussion (Misc queries) 0 February 18th 09 03:52 PM
Close Internet connection donbowyer Excel Programming 4 November 9th 05 02:04 PM
Internet Connection Web_Builder[_2_] Excel Programming 2 August 11th 04 01:07 AM
Internet connection? Francis Ang Excel Programming 3 May 31st 04 04:01 AM


All times are GMT +1. The time now is 11:16 AM.

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"