Could someone write some code that maps a network drive. This is tricky part. Write it as sammal as you can, no error control even. I'm trying to learn it starting simple. Thanks for any help
Printable View
Could someone write some code that maps a network drive. This is tricky part. Write it as sammal as you can, no error control even. I'm trying to learn it starting simple. Thanks for any help
You need to use the WNetAddConnection function for this.
'Declare the API call
Declare Function WNetAddConnection Lib "mpr.dll" Alias _
"WNetAddConnectionA" (byval lpszNetPath as string, _
byval lpszPassword as string, byval lpszLocalName _
as string) as Long
'Now We can use it somewhere
sShare = "//MyServer/MyShare"
sPwd = vbNullString
sDriveLetter = "X:"
lngResult = WNetAddConnection(sShare, sPwd, sDriveLetter)
I'm not sure where to put all the code. do i put all of it in a new module. what part do i put in a command button
Put the Declare statement in a standard module (be sure to place the keyword Public before it). Declares can only be placed in standard modules. The other code you can put wherever you like (e.g. Command1_Click()).