Check is this VBA-Excel file is running from a shared folder (Starts with \\)
Then shows a message to user, and exits tool or not is caller asked
Function RunFromShared(Optional Msg = "", Optional ThenExit = 1) As Boolean
' Check if file is ran from shared folder (starts with "\\")
RunFromShared = False
mypath = ThisWorkbook.Path
If InStr(1, mypath, "\AppData\Local\", vbTextCompare) > 0 Then
If Msg = "" Then Msg = "You may not run this tool from a shared location" & _
vbCrLf & "Please copy to your local drive then run"
MsgBox Msg
If ThenExit = 1 Then ThisWorkbook.Close False
End If
End Function
' Check if file is ran from shared folder (starts with "\\")
RunFromShared = False
mypath = ThisWorkbook.Path
If InStr(1, mypath, "\AppData\Local\", vbTextCompare) > 0 Then
If Msg = "" Then Msg = "You may not run this tool from a shared location" & _
vbCrLf & "Please copy to your local drive then run"
MsgBox Msg
If ThenExit = 1 Then ThisWorkbook.Close False
End If
End Function
Optional Msg, Optional ThenExit
Views 3,240
Downloads 1,387
CodeID
DB ID
ANmarAmdeen
607
Revisions
v1.0
Thursday
August
9
2018