I am trying to find a function such as Environto find on which drive the main drive in my business was mapped to a particular PC.
Using the file path "G: \ Eworking \ SET \ Operations \ file" I know that my computer was displayed so that this file path is inside the G drive, but others may be displayed differently, so I would like to determine .
I tried using the if else method through the alphabet and do it if Dir([filepath]) thenearlier (see below), but I was wondering if there is a better way to do this?
Sub LoopThroughDrives()
sFilePath As String
sFilePath = ":\Eworking\SET\Operations\file"
If Dir("A" & sFilePath) > 0 Then
msgbox ("It in drive A")
Else
If Dir("B" & sFilePath) > 0 Then
msgbox ("It in drive B")
Else
If Dir("C" & sFilePath) > 0 Then
msgbox ("It in drive C")
Else
'...........................
'All other letters of the alphabet, checking each possibility
'...........................
End If
End If
End If
End Sub
source
share