Hi
Is there a way of taking a folder path:
G:\folder
and finding the full path, for example:
\\server\sup\folder
Thanks a lot
Hi
Is there a way of taking a folder path:
G:\folder
and finding the full path, for example:
\\server\sup\folder
Thanks a lot
See this link:
http://www.dailydoseofexcel.com/arch...mapped-drives/
Let us know if it helps you.
Regards,
--------------------------------------------------------------------------------------------------------
Shrivallabha
--------------------------------------------------------------------------------------------------------
Using Excel 2016 in Home / 2010 in Office
--------------------------------------------------------------------------------------------------------
Thanks, this does work if the drive letter is upper case.
Can it be made case insensitive, I have tried including some Ucase() functions so far.
[VBA]'Switch on Windows Script Host Object Model in the Visual Basic Editor references
Public Function ConvertMapped(ByVal sPath As String) As String
Dim wsNet As WshNetwork
Dim wsDrives As WshCollection
Dim i As Long
Dim sReturn As String
Set wsNet = New WshNetwork
Set wsDrives = wsNet.EnumNetworkDrives
sReturn = sPath
For i = 0 To wsDrives.Count - 1
If Left$(sPath, 2) = wsDrives.Item(i) Then
sReturn = Replace(sPath, wsDrives.Item(i), wsDrives.Item(i + 1), 1, 1)
Exit For
End If
Next i
ConvertMapped = sReturn
End Function
[/VBA]
[VBA] If LCase(Left$(sPath, 2)) = LCase(wsDrives.Item(i)) Then[/VBA]
Thanks, I've now tried that with LCase and UCase but
Z:\ returns the full path and
z:\ just returns "z:\"
I've made sure that the path going in to the function is uppercase by making both instances of sPath uppercase.
[VBA]'Switch on Windows Script Host Object Model in the Visual Basic Editor references
Public Function ConvertMapped(ByVal sPath As String) As String
Dim wsNet As WshNetwork
Dim wsDrives As WshCollection
Dim i As Long
Dim sReturn As String
Dim sUpperPath As String
Set wsNet = New WshNetwork
Set wsDrives = wsNet.EnumNetworkDrives
sUpperPath = UCase(sPath)
sReturn = sUpperPath
For i = 0 To wsDrives.Count - 1
If Left$(sUpperPath, 2) = wsDrives.Item(i) Then
sReturn = Replace(sUpperPath, wsDrives.Item(i), wsDrives.Item(i + 1), 1, 1)
Exit For
End If
Next i
ConvertMapped = sReturn
End Function[/VBA]
Thanks for help all.
Last edited by sassora; 06-24-2012 at 01:50 AM.