BoobooBear
Technical User
I am trying to use the Windows Script Host from a VBA module to map a drive letter to a share drive on a remote server across a Novell network. I want to use another user's credentials (userid and password) as they have been set up with the appropriate permissions. I am using the following code:
I have included a reference to the Windows Host Script Object Model (ver 1.0) in my project.
My problem is that I am getting an automation error message on the "wshNetwork.MapNetworkDrive ..." line when I attempt to map to the remote server. It seems the userid and password arguments are not being recognised, as the above function will allow me to map to a share drive which I have rights to under my current (logged in) userid even if I include the final 2 arguments, giving them nonsense values. The function also works if I log into the remote server with the appropriate userid and password. I've checked the syntax again and again but can't see where I'm going wrong. (I've also confirmed that the values I'm using for the userid and password are correct!) I have a feeling there's a very simple answer. Can anyone help please?
Code:
Public Function MapDrive()
Dim wshNetwork As IwshNetwork
Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "E:", "\\SERVERNAME\VOLNAME", _
False, "UserId", "Password"
End Function
My problem is that I am getting an automation error message on the "wshNetwork.MapNetworkDrive ..." line when I attempt to map to the remote server. It seems the userid and password arguments are not being recognised, as the above function will allow me to map to a share drive which I have rights to under my current (logged in) userid even if I include the final 2 arguments, giving them nonsense values. The function also works if I log into the remote server with the appropriate userid and password. I've checked the syntax again and again but can't see where I'm going wrong. (I've also confirmed that the values I'm using for the userid and password are correct!) I have a feeling there's a very simple answer. Can anyone help please?