To get the full network path of mapped drive in windows, you can use the below VBA function. The function returns the full path on input of drive name like "Z:\" , "K", "T"
VBA Code:
Function GetNetworkPath(strDrive As String)
Dim oShell As Object, fso As Object, objFolder As Object Dim remPath As String Set oShell = CreateObject("WScript.Shell") On Error GoTo PathNotExist: remPath = oShell.RegRead("HKEY_CURRENT_USER\Network\" & Left(strDrive, 1) & "\RemotePath") Set fso = CreateObject("Scripting.FileSystemObject") If Len(strDrive) > 1 Then GetNetworkPath = remPath & Replace(strDrive, fso.GetDriveName(strDrive), "") Else GetNetworkPath = remPath End If PathNotExist: Exit Function End Function Example :
=GetNetworkPath("Z") will give you \\205.44.32.41\Excel\
Bouns Tip :
To map network drive in Windows, follow below steps :
1) My Computer
2) Tools --> Map Network Drive
3) Select Drive name
4) Provide Network Path
5) Finish
|
Learn Macros > VBA Macros >