Greetings Dr. K,
Both 'USERPROFILE' and 'WINDIR' returned the letter to the hard drive for me, so not sure if this will help. Maybe check the Drive Type.
Option Explicit
Sub ex()
Dim TextString As String
If Not AcceptableDrive(TextString) Then
MsgBox TextString, vbCritical, "File not local!"
ThisWorkbook.Close False
End If
End Sub
Function AcceptableDrive(msg As String) As Boolean
Dim FSO As Object '<--- FileSystemObject
Dim fsoThisWorkbook_Drive As Object '<--- Drive
Const DRV_UNKNOWN = 0
Const DRV_REMOVABLE = 1
Const DRV_FIXED = 2
Const DRV_NETWORK = 3
Const DRV_CDROM = 4
Const DRV_RAM = 5
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fsoThisWorkbook_Drive = FSO.GetDrive(FSO.GetDriveName(ThisWorkbook.Path))
Select Case fsoThisWorkbook_Drive.DriveType
Case 0, 1, 5
msg = "It appears you have this file stored in a removable (or unknown) storage device."
Case 2
AcceptableDrive = True
Exit Function
Case 3
msg = "It appears you have this file stored in a network folder."
Case 4
msg = "It appears you have this file stored in a CD."
End Select
msg = msg & "This tool can not be run from this location." _
& vbLf & vbLf & "Copy the .xls file to your desktop, and open it from there."
End Function
Hope that helps,
Mark