Check connectivity to network drive

S

Suthee

I have another probably simple question.

I need to check to see if a connection to a network drive exsists before I
execute some code. If the drive does not exsist, I need to terminate the
proceedure, with a simple msgbox.

Is there a way to do this?

My network drive is \\jupiter\output


Any ideas?

Thanks.
 
D

Dirk Goldgar

Suthee said:
I have another probably simple question.

I need to check to see if a connection to a network drive exsists
before I execute some code. If the drive does not exsist, I need to
terminate the proceedure, with a simple msgbox.

Is there a way to do this?

My network drive is \\jupiter\output


Any ideas?

You could use the Dir() function to read the directory and see if an
error is raised:

Dim strDummy As String

On Error Resume Next
strDummy = Dir(\\jupiter\output)
If Err.Number <> 0 Then
' The directory isn't accessible
' The error number will probably be 52.
End If

Note: in the above code, the directory name literal string should be
enclosed in quotes, but when I wrote this message, Outlook Express
"helpfully" removed them to make it a hyperlink.
 

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

Top