Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Network Computer Offline

How do you tell when a network computer is offline? Is there a code that
returns a value when a computer is on or offline?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Network Computer Offline

You need to ping the computer using the IP address or the network name. The
webpage below using the Win32 API IsDestinationReachable to accomplish this
task.


http://forums.devshed.com/visual-bas...ba-328706.html

"Philosophaie" wrote:

How do you tell when a network computer is offline? Is there a code that
returns a value when a computer is on or offline?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Network Computer Offline

This is what I have thus far:

Private Declare Function IsDestinationReachable Lib "//HPNC6220"
Sub Button1_Click()
If IsDestinationReachable(//HPNC6220, Ret) = 0 Then
MsgBox "The destination cannot be reached!"
Else
MsgBox "The destination can be reached!"
End If
End Sub

I want to ping the network computer \\HPNC6220 then use
IsDestinationReachable Lib to sort with an if-then to sort the results.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Network Computer Offline

The library "SENSAPI.DLL" is in the windows/system32 folder on your PC and
you cannot change the defination of the library. The function
IsDestinationReachable is in this library and the parameter can't be
modified. Copy the code below exactly as posted.

The library needs to know the lenght of the record returned so you need to
include this line: Ret.dwSize = Len(Ret)

Const NETWORK_ALIVE_AOL = &H4
Const NETWORK_ALIVE_LAN = &H1
Const NETWORK_ALIVE_WAN = &H2
Private Type QOCINFO
dwSize As Long
dwFlags As Long
dwInSpeed As Long 'in bytes/second
dwOutSpeed As Long 'in bytes/second
End Type
Private Declare Function IsDestinationReachable Lib "SENSAPI.DLL" _
Alias "IsDestinationReachableA" _
(ByVal lpszDestination As String, ByRef lpQOCInfo As QOCINFO) As Long
Private Sub Form_Load()
Dim Ret As QOCINFO
Ret.dwSize = Len(Ret)
If IsDestinationReachable("//HPNC6220", Ret) = 0 Then
MsgBox "The destination cannot be reached!"
Else
MsgBox "The destination can be reached!"
End If
End Sub



"Philosophaie" wrote:

This is what I have thus far:

Private Declare Function IsDestinationReachable Lib "//HPNC6220"
Sub Button1_Click()
If IsDestinationReachable(//HPNC6220, Ret) = 0 Then
MsgBox "The destination cannot be reached!"
Else
MsgBox "The destination can be reached!"
End If
End Sub

I want to ping the network computer \\HPNC6220 then use
IsDestinationReachable Lib to sort with an if-then to sort the results.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Network Computer Offline

You dont need the two foward slashes infront of the network name. You can
test the name by doing the following

1) Open a dos window
2003: Start button RUN. In the run box type cmd.exe
2007: Start - Search box type CMD

A dos window should now be opened. Type the following

ping HPNC6220 (enter)


"Philosophaie" wrote:

This is what I have thus far:

Private Declare Function IsDestinationReachable Lib "//HPNC6220"
Sub Button1_Click()
If IsDestinationReachable(//HPNC6220, Ret) = 0 Then
MsgBox "The destination cannot be reached!"
Else
MsgBox "The destination can be reached!"
End If
End Sub

I want to ping the network computer \\HPNC6220 then use
IsDestinationReachable Lib to sort with an if-then to sort the results.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Network Computer Offline

I need this check to be part of a program, not just a one time thing.

When I copied and pasted the latest program you gave me I stored it and
started Excel from scratch. Envolking the "Private Sub Form_Load()
" but nothing happened. Neither of the MSGBOXes worked. I put the program
in Sheets(Sheet1) then ThisWorkbook still nothing. What am I doing wrong?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Network Computer Offline

I put the code in a module and single step through the code without any
problems. The cod eshould run from anyplace in the VBA project since it is
not refering to any sheets.

"Philosophaie" wrote:

I need this check to be part of a program, not just a one time thing.

When I copied and pasted the latest program you gave me I stored it and
started Excel from scratch. Envolking the "Private Sub Form_Load()
" but nothing happened. Neither of the MSGBOXes worked. I put the program
in Sheets(Sheet1) then ThisWorkbook still nothing. What am I doing wrong?

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
Network Computer Offline Philosophaie Excel Programming 1 July 20th 09 12:31 AM
Test If Workbook is Open in Network and On Users Computer RyanH Excel Programming 0 October 20th 08 02:36 PM
outlook is offline when my computer is online. maysam New Users to Excel 1 March 10th 08 12:08 PM
My computer will not save to my network drive helpsaving Excel Discussion (Misc queries) 1 April 19th 06 05:39 AM
Dynamic data exchange between two computer on a network with VBA Denis[_5_] Excel Programming 3 February 12th 04 04:41 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"