Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default if internet on then ... else ...

Give this one a go...

I got the function from
http://vbnet.mvps.org/index.html?cod...ectedstate.htm



Private Declare Function InternetGetConnectedState Lib "wininet" _
(ByRef dwFlags As Long, _
ByVal dwReserved As Long) As Long


Sub test()
If IsNetConnectOnline() = True Then
MsgBox "You are connected to the Internet"
ElseIf IsNetConnectOnline() = False Then
MsgBox "You are NOT connected to the Internet"
End If
End Sub


Private Function IsNetConnectOnline() As Boolean
'no flags needed here - the API returns True
'if there is a connection of any type
IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function







"pswanie" wrote in message
...
how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

i used the code and it does work but...

we use a network and the phone line goes in the same hub as the network. if
i simply unplug the adsl line it still say "you are connected to the net" if
i unplug my computer from the network hub it says "internet not connected"

will try on a computer with out network and see if it works

"Mark Ivey" wrote:

Give this one a go...

I got the function from
http://vbnet.mvps.org/index.html?cod...ectedstate.htm



Private Declare Function InternetGetConnectedState Lib "wininet" _
(ByRef dwFlags As Long, _
ByVal dwReserved As Long) As Long


Sub test()
If IsNetConnectOnline() = True Then
MsgBox "You are connected to the Internet"
ElseIf IsNetConnectOnline() = False Then
MsgBox "You are NOT connected to the Internet"
End If
End Sub


Private Function IsNetConnectOnline() As Boolean
'no flags needed here - the API returns True
'if there is a connection of any type
IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function







"pswanie" wrote in message
...
how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default if internet on then ... else ...

Here is another one you can try out. It has a function I was using with my
VB Scripting, but it should work in this scenario as well.

Just change the URL in the function call to whatever you think necessary for
an Internet connection type check.

Sub test2()
If IsAlive("www.google.com") = True Then ' change URL
as needed
MsgBox "You are connected to the Internet"
ElseIf IsAlive("www.google.com") = False Then ' change URL as
needed
MsgBox "You are NOT connected to the Internet"
End If
End Sub

Function IsAlive(strHost)
'---------- Test to see if host or url alive through ping -----------------
' Returns True if Host responds to ping '
' Function is compliments of Phil Gordemer, ARH Associates
' Found @ http://www.tek-tips.com/viewthread.c...1279504&page=3
'
' Though there are other ways to ping a computer, Win2K,
' XP and different versions of PING return different error
' codes. So the only reliable way to see if the ping
' was sucessful is to read the output of the ping
' command and look for "TTL="
'
' strHost is a hostname or IP
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Dim objShell, objFSO, sTempFile, fFile
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sTempFile = objFSO.GetSpecialFolder(2).ShortPath & "\" &
objFSO.GetTempName
objShell.Run "%comspec% /c ping.exe -n 2 -w 500 " & strHost & "" &
sTempFile, 0, True
Set fFile = objFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist,
OpenAsASCII)
Select Case InStr(fFile.ReadAll, "TTL=")
Case 0
IsAlive = False
Case Else
IsAlive = True
End Select
fFile.Close
objFSO.DeleteFile (sTempFile)
Set objFSO = Nothing
Set objShell = Nothing
End Function







"pswanie" wrote in message
...
i used the code and it does work but...

we use a network and the phone line goes in the same hub as the network.
if
i simply unplug the adsl line it still say "you are connected to the net"
if
i unplug my computer from the network hub it says "internet not connected"

will try on a computer with out network and see if it works

"Mark Ivey" wrote:

Give this one a go...

I got the function from
http://vbnet.mvps.org/index.html?cod...ectedstate.htm



Private Declare Function InternetGetConnectedState Lib "wininet" _
(ByRef dwFlags As Long, _
ByVal dwReserved As Long) As Long


Sub test()
If IsNetConnectOnline() = True Then
MsgBox "You are connected to the Internet"
ElseIf IsNetConnectOnline() = False Then
MsgBox "You are NOT connected to the Internet"
End If
End Sub


Private Function IsNetConnectOnline() As Boolean
'no flags needed here - the API returns True
'if there is a connection of any type
IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function







"pswanie" wrote in message
...
how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

Sub or function not defined....

i am still rather new to this...

how do i define a function and if u got time what exacly that mean and when
and how etc please...


Phillip


"Mark Ivey" wrote:

Here is another one you can try out. It has a function I was using with my
VB Scripting, but it should work in this scenario as well.

Just change the URL in the function call to whatever you think necessary for
an Internet connection type check.

Sub test2()
If IsAlive("www.google.com") = True Then ' change URL
as needed
MsgBox "You are connected to the Internet"
ElseIf IsAlive("www.google.com") = False Then ' change URL as
needed
MsgBox "You are NOT connected to the Internet"
End If
End Sub

Function IsAlive(strHost)
'---------- Test to see if host or url alive through ping -----------------
' Returns True if Host responds to ping '
' Function is compliments of Phil Gordemer, ARH Associates
' Found @ http://www.tek-tips.com/viewthread.c...1279504&page=3
'
' Though there are other ways to ping a computer, Win2K,
' XP and different versions of PING return different error
' codes. So the only reliable way to see if the ping
' was sucessful is to read the output of the ping
' command and look for "TTL="
'
' strHost is a hostname or IP
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Dim objShell, objFSO, sTempFile, fFile
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sTempFile = objFSO.GetSpecialFolder(2).ShortPath & "\" &
objFSO.GetTempName
objShell.Run "%comspec% /c ping.exe -n 2 -w 500 " & strHost & "" &
sTempFile, 0, True
Set fFile = objFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist,
OpenAsASCII)
Select Case InStr(fFile.ReadAll, "TTL=")
Case 0
IsAlive = False
Case Else
IsAlive = True
End Select
fFile.Close
objFSO.DeleteFile (sTempFile)
Set objFSO = Nothing
Set objShell = Nothing
End Function







"pswanie" wrote in message
...
i used the code and it does work but...

we use a network and the phone line goes in the same hub as the network.
if
i simply unplug the adsl line it still say "you are connected to the net"
if
i unplug my computer from the network hub it says "internet not connected"

will try on a computer with out network and see if it works

"Mark Ivey" wrote:

Give this one a go...

I got the function from
http://vbnet.mvps.org/index.html?cod...ectedstate.htm



Private Declare Function InternetGetConnectedState Lib "wininet" _
(ByRef dwFlags As Long, _
ByVal dwReserved As Long) As Long


Sub test()
If IsNetConnectOnline() = True Then
MsgBox "You are connected to the Internet"
ElseIf IsNetConnectOnline() = False Then
MsgBox "You are NOT connected to the Internet"
End If
End Sub


Private Function IsNetConnectOnline() As Boolean
'no flags needed here - the API returns True
'if there is a connection of any type
IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function







"pswanie" wrote in message
...
how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

wups silly me... did not read ur full post.

thanx

"Mark Ivey" wrote:

Here is another one you can try out. It has a function I was using with my
VB Scripting, but it should work in this scenario as well.

Just change the URL in the function call to whatever you think necessary for
an Internet connection type check.

Sub test2()
If IsAlive("www.google.com") = True Then ' change URL
as needed
MsgBox "You are connected to the Internet"
ElseIf IsAlive("www.google.com") = False Then ' change URL as
needed
MsgBox "You are NOT connected to the Internet"
End If
End Sub

Function IsAlive(strHost)
'---------- Test to see if host or url alive through ping -----------------
' Returns True if Host responds to ping '
' Function is compliments of Phil Gordemer, ARH Associates
' Found @ http://www.tek-tips.com/viewthread.c...1279504&page=3
'
' Though there are other ways to ping a computer, Win2K,
' XP and different versions of PING return different error
' codes. So the only reliable way to see if the ping
' was sucessful is to read the output of the ping
' command and look for "TTL="
'
' strHost is a hostname or IP
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Dim objShell, objFSO, sTempFile, fFile
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sTempFile = objFSO.GetSpecialFolder(2).ShortPath & "\" &
objFSO.GetTempName
objShell.Run "%comspec% /c ping.exe -n 2 -w 500 " & strHost & "" &
sTempFile, 0, True
Set fFile = objFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist,
OpenAsASCII)
Select Case InStr(fFile.ReadAll, "TTL=")
Case 0
IsAlive = False
Case Else
IsAlive = True
End Select
fFile.Close
objFSO.DeleteFile (sTempFile)
Set objFSO = Nothing
Set objShell = Nothing
End Function







"pswanie" wrote in message
...
i used the code and it does work but...

we use a network and the phone line goes in the same hub as the network.
if
i simply unplug the adsl line it still say "you are connected to the net"
if
i unplug my computer from the network hub it says "internet not connected"

will try on a computer with out network and see if it works

"Mark Ivey" wrote:

Give this one a go...

I got the function from
http://vbnet.mvps.org/index.html?cod...ectedstate.htm



Private Declare Function InternetGetConnectedState Lib "wininet" _
(ByRef dwFlags As Long, _
ByVal dwReserved As Long) As Long


Sub test()
If IsNetConnectOnline() = True Then
MsgBox "You are connected to the Internet"
ElseIf IsNetConnectOnline() = False Then
MsgBox "You are NOT connected to the Internet"
End If
End Sub


Private Function IsNetConnectOnline() As Boolean
'no flags needed here - the API returns True
'if there is a connection of any type
IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function







"pswanie" wrote in message
...
how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

works perfect....

do thank u!!

Phillip

"pswanie" wrote:

how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default if internet on then ... else ...

No problem...

Glad it worked for you.

Mark

"pswanie" wrote in message
...
works perfect....

do thank u!!

Phillip

"pswanie" wrote:

how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

how will i get true in cell k1 if internet on and false in sell k1 if not
connected?

im gona put the code in the workbook open. got a Wait while loading form
allready.

how will i code a command button to check the value of cell k1?

"Mark Ivey" wrote:

No problem...

Glad it worked for you.

Mark

"pswanie" wrote in message
...
works perfect....

do thank u!!

Phillip

"pswanie" wrote:

how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default if internet on then ... else ...

got it. it all work good now

thanx

"Mark Ivey" wrote:

No problem...

Glad it worked for you.

Mark

"pswanie" wrote in message
...
works perfect....

do thank u!!

Phillip

"pswanie" wrote:

how would i do this? we use always on adsl but will use this on a few
computers with out internet connection

workbook_open

if internet = on
then
run userform1
else
run userform4
end if
end sub




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
XLT and Internet Emece Excel Discussion (Misc queries) 6 April 6th 10 03:56 PM
VBA and internet dr chuck Excel Programming 1 November 26th 06 05:03 PM
VBA for getting files off internet Btibert[_12_] Excel Programming 3 April 30th 06 03:25 AM
Excel & internet kapil.dalal Excel Discussion (Misc queries) 0 May 30th 05 12:55 PM
Excel as a DB on the internet Stu McLeod Excel Programming 0 August 29th 03 04:43 PM


All times are GMT +1. The time now is 04:38 PM.

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"