Accessibility of a server

  • Thread starter Thread starter Stefi
  • Start date Start date
S

Stefi

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
 
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
 
Thanks Jim, I immediately start testing, I'll post the result.
Stefi


„Jim Cone†ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top