Restricted Saving of workbook


Posted by Mike Smith on November 12, 2001 5:20 AM

Does anyone have some code that will only allows users to save a shared workbook between certain hours of the day?



Posted by Barrie Davidson on November 12, 2001 8:53 AM

Try inserting these two sub-routines in the workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Time >= TimeValue("08:30") And Time <= TimeValue("17:00") Then
Else
Me.Saved = True
End If
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Time >= TimeValue("08:30") And Time <= TimeValue("17:00") Then
Else
Cancel = True
End If
End Sub

Of course, you'll need to change the start and end times (08:30 and 17:00) to your required times.

Regards,
BarrieBarrie Davidson