Hi all,
I have got the following Macro so a workbook does not stay open on somebodies computer. However even after it closes it reopens and prompts me to enable macros and when I do it closes again. I thought I had put in another Macro that stops that as soon as the workbook is closed. Could somebody tell me why this is not working?
The following is in the "thisworkbook" object.
In a serperate Module.
Your help would be greatly appreciated.
I have got the following Macro so a workbook does not stay open on somebodies computer. However even after it closes it reopens and prompts me to enable macros and when I do it closes again. I thought I had put in another Macro that stops that as soon as the workbook is closed. Could somebody tell me why this is not working?
The following is in the "thisworkbook" object.
Code:
Private Sub Workbook_Open()
Sheets("pp").Select
Range("G5:L5").Select
dtmSchedule = Now + TimeValue("01:00:00")
Application.OnTime dtmSchedule, "TimeOut"
If ThisWorkbook.ReadOnly Then
MsgBox ("The file is currently being used by another user, please contact them to ensure they have not left the file open.")
ThisWorkbook.Close SaveChanges:=False
End If
With Worksheets("PP")
.Protect Password:="bargy", userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime dtmSchedule, "TimeOut", , False
End Sub
In a serperate Module.
Code:
Sub TimeOut()
ThisWorkbook.Close SaveChanges:=True
End Sub
Your help would be greatly appreciated.