map network drive

L

lumpy04

Hello,

I would like to map a network drive when I open the worksheet. Something Like

Private Sub worksheet_open()
Net use y: \\server\share password /user ID
end sub

Can anyone help?
 
G

Gary''s Student

Something like:

Sub map_um()
dq = Chr(34)
s = "net use z: /delete /y"
ss = "net use z: " & dq & "\\MAINSERVER\Shared" & dq & " /PERSISTENT:no"
x = Shell("cmd.exe /c" & s, 1)
x = Shell("cmd.exe /c" & ss, 1)
End Sub

Note I use the variable dq as I always have trouble embedding double quotes
in a string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top