How to Connect Network Drive
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 'Network - How to Connect Network Drive Option Explicit Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal _ lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long Public Function ConnectIt(ByVal sNetworkShare As String, ByVal sDriveLetter As String, _ Optional ByVal sPassword As String = "") 'Inputs - sDriveLetter - Drive letter which needs to be disconnected ' sPassword - Password to connect Network Drive ' sNetworkShare - Network Share name 'Returns - True - if Drive is Connected ' False - if Drive is not Connected 'Usage - MsgBox ConnectIt("\\TestServer\TestShare", "Q:", "") ConnectIt = WNetAddConnection(sNetworkShare, sPassword, sDriveLetter) End Function |