RunFromShared

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

Parameters

Optional Msg, Optional ThenExit

Views 62 Downloads 17

Perm link