Hi all,
I've done a fair amount of searching and trying different methods myself; however, I am unable to map a drive letter to a local folder on my machine.
This thread shows how to map to a network drive, and it works well for actual network locations: https://www.mrexcel.com/forum/excel-questions/284297-map-network-drive-using-excel-macro.html
For mapping to a local folder, I can do this in CMD using subst, so I have tried several permutations of this code:
This code opens CMD; however the N: drive is not 'mapped' and I can't seem to get it to work.
Any ideas for what to try?
Thanks,
Josh
I've done a fair amount of searching and trying different methods myself; however, I am unable to map a drive letter to a local folder on my machine.
This thread shows how to map to a network drive, and it works well for actual network locations: https://www.mrexcel.com/forum/excel-questions/284297-map-network-drive-using-excel-macro.html
For mapping to a local folder, I can do this in CMD using subst, so I have tried several permutations of this code:
Code:
Private Sub mapdrive2()
Dim MyDriveName As String
Dim MyDrive As Object
MyDriveName = """C:\Users\me\"""
Call Shell("cmd.exe Subst N: " & MyDriveName, vbNormalFocus)
'- error check
If Err.Number <> 0 Then
MsgBox (" Drive already mapped or not available ")
Else
MsgBox ("Mapped OK")
End If
Set MyDrive = Nothing
End Sub
This code opens CMD; however the N: drive is not 'mapped' and I can't seem to get it to work.
Any ideas for what to try?
Thanks,
Josh