Function Path2UNC(sFullName As String) As String
' Converts the mapped drive path in sFullName to a UNC path if one exists.
' If not, returns a null string
Dim sDrive As String
Dim i As Long
sDrive = UCase(Left(sFullName, 2))
With CreateObject("WScript.Network").EnumNetworkDrives
For i = 0 To .Count - 1 Step 2
If .Item(i) = sDrive Then
Path2UNC = .Item(i + 1) & Mid(sFullName, 3)
Exit For
End If
Next
End With
End Function
Dim sUNC As String
sUNC = Path2UNC("X:\myPath\myFile.xls")
If Len(Dir(sUNC)) Then
Workbooks.Open sUNC
' ...
End With
.All the answers I can find on the web are all about checking to see whether a file exists, and don't offer any information whatsoever about actually incorporating the UNC path into the open method's filename argument
Workbooks.Open("\\server1\folder1\Book1.xls")