LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Return network share/drive letter equivalent

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtain drive letter assignment of CD/DVD drive? EagleOne Excel Discussion (Misc queries) 1 October 13th 06 01:27 PM
user cannot access his share workbook on network drive. Phil Excel Worksheet Functions 0 September 26th 06 04:30 PM
Pivot table vs DB on share drive TotallyConfused Excel Discussion (Misc queries) 0 March 8th 06 01:20 AM
Link workbooks-C drive to network drive Earl Excel Worksheet Functions 0 April 19th 05 05:50 PM
Userform Local Drive & Network drive question Joel Mills Excel Programming 3 December 29th 04 10:43 PM


All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"