Login to network drive help

Apuokas

New Member
Joined
Oct 28, 2013
Messages
3
Hi all,

I'm trying to create a macro, that would map a network drive to a letter, login, and post some files there. I have been able to accomplish all but the login part, which is a bit of a pain... Below is what I've got so far:

Sub MapDrive()
' =================== MAP DRIVE Z ===================
Dim MyDrive As Object
Dim MyDriveName As String
MyDriveName = \\blahblah\folder\

'------------------------------------------------------------
'- map drive
On Error Resume Next ' DRIVE MAY BE MAPPED ALREADY
Set MyDrive = CreateObject("WScript.Network")
MyDrive.MapNetworkDrive "Z:", MyDriveName
DoEvents

Shell "explorer.exe " & "Z:\", vbNormalFocus

End Sub


Basically, I need some code after the "Shell explorer..." to fill in login info into a message box that pops up and 'click' ok, close the folder, after which another macro continues to post files into the drive.

I've been searching for a solution for a while, but I can only locate some gmail examples... Any ideas?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Thanks, I guess I was searching the wrong keywords the whole time.

Anyways, I've tried the code, but I keep getting a "false" as the result. I found another post where someone had the same problem, but no resolution. Have ideas what could cause this?
 
Upvote 0
Actually just found a much simpler solution!

Dim objNetwork
Dim strDriveLetter
Dim strRemotePath
Dim strUserName
Dim strPassWord
strDriveLetter = "G:"
strRemotePath = "\\ServerName\FolderName"
Set objNetwork = CreateObject("WScript.Network")
strUserName = "Username"
strPassWord = "Password"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, , strUserName, strPassWord
MsgBox "The Script Has Executed Successfully!"


Thanks for leading me on the right track ;)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top