ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accessibility of a server (https://www.excelbanter.com/excel-programming/405792-accessibility-server.html)

Stefi

Accessibility of a server
 
Hi All,

I have to check whether a file exists on a remote server or not. DIR works
when the server is accessible, but doesn't reply if connection is broken and
keeps searching the file ad infinitum, I can't even interrupt running the
macro (neither with Esc nor with Task manager).

Is there any way to detect the accessibility of the server before using DIR?

Thanks,
Stefi


Jim Cone

Accessibility of a server
 

I am not on a network to test it, but the FileSystemObject should be able to do it...
'--
Sub ProvidePath()
Dim strPath As String
strPath = "FillInPathToTheFileOnTheServer" '<<<<<
MsgBox ReportFileStatus(strPath)
End Sub
'--
Function ReportFileStatus(ByRef fileSpec As String) as String
Dim fso As Object
Dim msg As String
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(fileSpec)) Then
msg = fileSpec & " exists."
Else
msg = fileSpec & " doesn't exist."
End If
ReportFileStatus = msg
Set fso = Nothing
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - check out "List Files" )



"Stefi"
wrote in message
Hi All,
I have to check whether a file exists on a remote server or not. DIR works
when the server is accessible, but doesn't reply if connection is broken and
keeps searching the file ad infinitum, I can't even interrupt running the
macro (neither with Esc nor with Task manager).

Is there any way to detect the accessibility of the server before using DIR?

Thanks,
Stefi


Stefi

Accessibility of a server
 
Thanks Jim, I immediately start testing, I'll post the result.
Stefi


€˛Jim Cone€¯ ezt Ć*rta:


I am not on a network to test it, but the FileSystemObject should be able to do it...
'--
Sub ProvidePath()
Dim strPath As String
strPath = "FillInPathToTheFileOnTheServer" '<<<<<
MsgBox ReportFileStatus(strPath)
End Sub
'--
Function ReportFileStatus(ByRef fileSpec As String) as String
Dim fso As Object
Dim msg As String
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(fileSpec)) Then
msg = fileSpec & " exists."
Else
msg = fileSpec & " doesn't exist."
End If
ReportFileStatus = msg
Set fso = Nothing
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - check out "List Files" )



"Stefi"
wrote in message
Hi All,
I have to check whether a file exists on a remote server or not. DIR works
when the server is accessible, but doesn't reply if connection is broken and
keeps searching the file ad infinitum, I can't even interrupt running the
macro (neither with Esc nor with Task manager).

Is there any way to detect the accessibility of the server before using DIR?

Thanks,
Stefi



Jim Cone

Accessibility of a server
 

Please do.
---
Jim Cone



"Stefi"

wrote in message
Thanks Jim, I immediately start testing, I'll post the result.
Stefi




urkec

Accessibility of a server
 
"Stefi" wrote:

Thanks Jim, I immediately start testing, I'll post the result.
Stefi



€˛Jim Cone€¯ ezt Ć*rta:


I am not on a network to test it, but the FileSystemObject should be able to do it...


Is there any way to detect the accessibility of the server before using DIR?


You can also use ping command to check if your server is accesible. Here is
some sample code from Richard Mueller's site:

http://www.rlmueller.net/Programs/Ping2.txt

--
urkec


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com