List of Drives

mjbeam

Well-known Member
Joined
Apr 6, 2002
Messages
756
Is there an easy way to retrieve a list of mapped drives in VBA or is it easier to just use system calls?


Thanks...Mike
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
In VBA Help look for information on "Drive Collection"

Here's the code supplied in the VBA Help file ... I've modified slightly to allow for drives that "aren't ready".

Sub ShowDriveList()
Dim fs, d, dc, s, n
Set fs = CreateObject("Scripting.FileSystemObject")
Set dc = fs.Drives
For Each d In dc
s = s & d.DriveLetter & " - "
If d.DriveType = Remote Then
On Error Resume Next
n = d.ShareName
Else
On Error Resume Next
n = d.VolumeName
End If
s = s & n & vbCrLf
Next
MsgBox s
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top