Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using Office 2003 on Windows XP.
I need some help coding a function that when supplied with a full path and file name and the drive is a network share, it returns the equivalent drive letter - if one is mapped - otherwise empty string; if the drive is a mapped letter, return the equivalent network share. For non-network drives, just return the drive letter. For example: 1) \\network\share\myData\subfolder\MyFile.xls Would return: I:\ (assuming \\network\share\ is mapped to letter "I") BUT, if this is an unmapped network share then an empty string would be returned 2) I:\myData\subfolder\MyFile.xls would return: \\network\share\ 3) C:\subfolder\MyFile.xls Would return: C:\ Below is my incomplete start on a function, but I'm having trouble: Public Function DriveNameEquivalent(argFullName As String) As String 'IF NETWORK SHARE SUPPLIED - RETURNS EQUIV DRIVE LETTER - & - VICE VERSA Dim oFSO As Object Dim oDrives As Object Dim oDrive As Object Dim strLetter As String Set oFSO = CreateObject("Scripting.FileSystemObject") Set oDrives = oFSO.drives For Each oDrive In oDrives If UCase(oDrive.ShareName) = UCase(oFSO.GetAbsolutePathName(argFullName)) Then strLetter = oDrive.DriveLetter: Exit For Next oDrive Exit Function Thanks much in advance for your assistance. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Obtain drive letter assignment of CD/DVD drive? | Excel Discussion (Misc queries) | |||
user cannot access his share workbook on network drive. | Excel Worksheet Functions | |||
Pivot table vs DB on share drive | Excel Discussion (Misc queries) | |||
Link workbooks-C drive to network drive | Excel Worksheet Functions | |||
Userform Local Drive & Network drive question | Excel Programming |