I have this code which I need to test the file path, as if your are working offline then the file path will not exist. It will only work if you are connected to the server.
Private Sub Workbook_Open()
Dim sFolderPath As String
Dim sCurrentWorkbookName As String
sFolderPath = "\\ SHARED\Public Folder\Switch Off"
If Right(sFolderPath, 1) <> "\" Then
sFolderPath = sFolderPath & "\"
End If
Application.DisplayAlerts = False
If Dir(sFolderPath, vbDirectory) <> vbNullString Then
sCurrentWorkbookName = ThisWorkbook.Name
Open "\\SHARED\Public Folder\ Switch Off\Log.txt" For Append As #1
Print #1, Format(Now, "dd/mm/yyyy hh:mm:ss"); ","; Environ("username"); ","; sCurrentWorkbookName; ","
Close #1
Else
Exit Sub
End If
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Open()
Dim sFolderPath As String
Dim sCurrentWorkbookName As String
sFolderPath = "\\ SHARED\Public Folder\Switch Off"
If Right(sFolderPath, 1) <> "\" Then
sFolderPath = sFolderPath & "\"
End If
Application.DisplayAlerts = False
If Dir(sFolderPath, vbDirectory) <> vbNullString Then
sCurrentWorkbookName = ThisWorkbook.Name
Open "\\SHARED\Public Folder\ Switch Off\Log.txt" For Append As #1
Print #1, Format(Now, "dd/mm/yyyy hh:mm:ss"); ","; Environ("username"); ","; sCurrentWorkbookName; ","
Close #1
Else
Exit Sub
End If
Application.ScreenUpdating = True
End Sub