I have a macro-enabled workbook which is read-only (data is recorded on the workbook through the use of macros). I need it to automatically save when closed. The following code saves the workbook on closing but it doesn't save the data recorded by the macros.
I've tried adding in the remove read-only attribute and add read-only attribute at the start and end of the above code but this just alerts that somebody else is in the workbook.
Any help appreciated
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = False
End Sub
I've tried adding in the remove read-only attribute and add read-only attribute at the start and end of the above code but this just alerts that somebody else is in the workbook.
Any help appreciated