techuser123
Technical User
Attached is an excerpt of the VBA code I use in Access to remap a drive. When the drive is not in use, it gets mapped without a problem. When it is in use, the RemoveNetworkDrive works (no error), but the share name that I see in explorer doesn't change. If I step through the code, I see the mapped drive get disconnected, and the new share get created with the correct name. What am I doing wrong? What is different from when I run the code as opposed to stepping through it?
Set nw = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.DriveExists("Y:") Then
nw.RemoveNetworkDrive "Y:", True, True
Sleep 300
End If
nw.MapNetworkDrive "Y:", sShare, False
Set fso = Nothing
Set nw = Nothing
I noticed other threads on here with similar problems, but never found an answer to what I am experiencing.
Thanks in advance for any help!
Set nw = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.DriveExists("Y:") Then
nw.RemoveNetworkDrive "Y:", True, True
Sleep 300
End If
nw.MapNetworkDrive "Y:", sShare, False
Set fso = Nothing
Set nw = Nothing
I noticed other threads on here with similar problems, but never found an answer to what I am experiencing.
Thanks in advance for any help!