+ Reply to Thread
Results 1 to 1 of 1

VBA - share name of a local drive

Hybrid View

katto01 VBA - share name of a local... 05-16-2013, 07:30 AM
  1. #1
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    VBA - share name of a local drive

    Hello,

    My drive c:\ is shared as \\computername\c1.
    I need to refer to it using its ShareName.

    I use the following:
    Public Sub test_ShowDriveInfo()
    Call ShowDriveInfo("c:\")
    End Sub
    Sub ShowDriveInfo(drvpath)
        Dim fs, d, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(drvpath)))
        s = "Drive " & d.DriveLetter & ": - " & d.ShareName
        MsgBox s
    End Sub
    It works OK for network drives. When I refer to local drives, the d.ShareName is empty.
    I need to get for “c:\”, d.ShareName =\\computername\c1.
    Any ideas?

    Thanks
    Last edited by arlu1201; 05-16-2013 at 08:54 AM. Reason: Use code tags in future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1