ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to get network drive mapping (https://www.excelbanter.com/excel-programming/351380-how-get-network-drive-mapping.html)

Raj

How to get network drive mapping
 
Hi

In an excel macro, I need to list all the drives available to a user and if
the drive is a network drive, then I need to list its mapping string eg
\\finance\restructre

Please can some one help, thanks in advance

Jim Cone

How to get network drive mapping
 
Raj,

This ought to get you close.
I am not on a network so I cannot determine how a network drive is listed.
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


'-----------------------------------
Private Sub GetAllDrives()
'Jim Cone - San Francisco, USA - January 2006
'Requires project reference to "Microsoft Scripting Runtime"
'Lists all drives and their types on the active sheet.
On Error GoTo Start_Error
Dim FSO As Scripting.FileSystemObject
Dim objAllDrives As Scripting.Drives
Dim objDrive As Scripting.Drive
Dim strLetter As String
Dim strType As String
Dim varTypes As Variant
Dim lngCount As Long
Dim lngRow As Long

Set FSO = New Scripting.FileSystemObject
Set objAllDrives = FSO.Drives
'Other in case a 'type' is added in the future.
varTypes = Array(" Unknown", " Removable", " Hard Drive", _
" Network", " CD/DVD", " RAM Disk", " Other")
lngRow = 1
For Each objDrive In objAllDrives
lngRow = lngRow + 1
strLetter = objDrive.Path
lngCount = objDrive.DriveType
strType = varTypes(lngCount)
Cells(lngRow, 2).Value = strLetter & strType
Next

Set objDrive = Nothing
Set objAllDrives = Nothing
Set FSO = Nothing
Exit Sub

Start_Error:
Beep
Resume Next
End Sub
'-----------------------


"Raj"
wrote in message
...
Hi
In an excel macro, I need to list all the drives available to a user and if
the drive is a network drive, then I need to list its mapping string eg
\\finance\restructre

Please can some one help, thanks in advance


All times are GMT +1. The time now is 07:55 AM.

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