Checking a net drive

  • Thread starter Thread starter Leif Rasmussen
  • Start date Start date
L

Leif Rasmussen

How do I check if a mapped drive is available and how do I
get a return value which can be used for testing the
avalability.
I psudocode something like:

If netdrive("Compagny-net/allusers") then
bla.. bla
end if

Kind regards
Leif Rasmussen
New in Excel VBA but facinated.
 
Leif,
You need a reference to "Microsoft Scripting Runtime" library
(C:\WINDOWS\SYSTEM32\SCRRUN.DLL). You can get to it via Tools | References
in the VBE (Visual Basic Editor).

It has a lot of great methods. Look through the object browser once
you've set the reference.

In the meantime....

sub test
Dim fso As Scripting.FileSystemObject
msgbox fso.Drives("D").IsReady
end sub


HTH,
Gary Brown
 
Is there a reason you don't want to work with the UNC name?

I know that we use a lot of shares at work and lots of times, the users map them
to different letters (if they're mapped at all).

I do a cheap and dirty test:

Option Explicit
Sub testme()

Dim myPathFolder As String
Dim testStr As String

myPathFolder = "\\sharename\folder1\folder2"
If Right(myPathFolder, 1) <> "\" Then
myPathFolder = myPathFolder & "\"
End If

testStr = ""
On Error Resume Next
testStr = Dir(myPathFolder & "nul")
On Error GoTo 0

If testStr = "" Then
MsgBox "path folder doesn't exist"
End If
End Sub
 

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