I need to get through VBA a folder hosted on a network file server. The folder is available in writing only through a service account (other than regular user accounts), for which I have a username and password.
Through the user interface, I can see this folder and display it as a local drive, but to access it in writing, I need to exit Windows and log in through the service account.
Is there a way to access the network folder during a regular user session, but the username is hardcoding and pwd in VBA code?
I tried to map the folder as a local drive using:
Set WshNetwork = CreateObject("WScript.Network") WshNetwork.MapNetworkDrive "S:", "\\corp-server\HostingFolder", False, Username, pwd
but does not work (drive "S" was not displayed). If instead I do the same, but without specifying a username and password:
Set WshNetwork = CreateObject("WScript.Network") WshNetwork.MapNetworkDrive "S:", "\\corp-server\HostingFolder"
It works great.
I wonder if what I'm trying to do can actually be possible? If not, is there an alternative?
thanks
source share