PC Review


Reply
Thread Tools Rate Thread

How to check for Internet connection

 
 
Vikram
Guest
Posts: n/a
 
      16th Jun 2006
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 With Quote
 
 
 
 
keepITcool
Guest
Posts: n/a
 
      16th Jun 2006

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
<news:<(E-Mail Removed)>

> 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 With Quote
 
Vikram
Guest
Posts: n/a
 
      16th Jun 2006
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
> <news:<(E-Mail Removed)>
>
> > 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 With Quote
 
Vikram
Guest
Posts: n/a
 
      16th Jun 2006
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
> <news:<(E-Mail Removed)>
>
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet connection check via vba? Ron Microsoft Excel Programming 2 27th Aug 2007 03:40 PM
Check for Internet Connection Wayne Wengert Windows XP General 1 1st Jun 2006 02:23 PM
Re: Check for Internet Connection Pegasus \(MVP\) Windows XP General 0 1st Jun 2006 02:20 PM
Internet Connection Check? David Pope Microsoft Dot NET Compact Framework 5 16th Mar 2005 11:18 AM
How can I check internet connection in vb Kadir CAMOGLU Microsoft Dot NET 1 8th Aug 2003 12:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:34 AM.