I'm using the following macro to suppress messages about there being things within the workbook that the document inspector can't remove. It works but when closing the file it enters an infinite loop of saving and then prompting me if I want to save changes.
How could I exit this loop after the first time it pops up?
How could I exit this loop after the first time it pops up?
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Application
.DisplayAlerts = False : .EnableEvents = False
ThisWorkbook.RemovePersonalInformation = True
ActiveWorkbook.Save
.EnableEvents = True : .ScreenUpdating = True : .DisplayAlerts = True
End With
ThisWorkbook.Saved = True
Cancel = True
End Sub