0
votes

I'm creating a dropdown list on open that populates the user's mapped network drives (drive letter) and any network locations (folder shortcut). Basically what you would see in the Network Locations section of My Computer/This PC.

Using VBA I know you can sift through mapped drives using the filescripting object but I've been unsuccessful getting network locations.

Trying the Wscript.Network object with the Object.enumNetworkDrives appeared to work fine at work yet doesn't appear to bring in the network locations while at home working remote.

Is there a different, better and/or more consistent method (with a good VBA example) to getting all the mapped drives and network locations using VBA?

1
You know I had seen that link and overlooked the tiny detail in the logic that actually pulls the Path of where all network locations are stored. Using the first few lines of that, looping through the sub folders to get the network location names and applying some of the WMI logic does the trick for all I need to do! Much appreciated! - stamp0307

1 Answers

4
votes

I suggest you have a look at WMI. Here's a short example to get you started:

Sub ListDrives()
    WQL = "Select * From Win32_LogicalDisk"
    Set SrvEx = GetObject("winmgmts:root/CIMV2")
    Set WMIObj = SrvEx.ExecQuery(WQL)
    For Each WMIObjEx In WMIObj
        Debug.Print WMIObjEx.Path_.RelPath
    Next
End Sub