How to remove Document Inspector warning in Excel
I'm running VBA scripts on a series of files that are XLSM type. While I'm trying to automate my processes, I'm getting stopped by this warning about the Document Inspector, meaning I have to click OK for every file.
Is there a script I can run on my files in advance, or embed one in my code, that will remove this warning?
Warning Message
Be careful! Parts of your document may include personal information that can't be removed by the Document Inspector.
Potential solutions to the "Be careful! Parts of your document may include personal information that can't be removed by the Document Inspector." warning message.
To remove Document Inspector warning in Excel 2016 or Excel 2013 you can check two things
- Go to File in the upper left hand corner,
- then Options > Trust Center > Trust Center Settings > Privacy Options
- then un-check the check box that says "Remove personal information from file properties on save",
- then hit OK.
Source
Or
- Go to File > Info
- and click in "Allow this information to be saved in your file".
The next time you save there should be no more warning.
Source
My Solution
Instead of disabling the Document Inspector which seems difficult to do in VB, I'm just blocking the message itself. I don't really care about the source file, I just want to seamlessly copy data out of them so this will work in my case just fine.
By adding this code to the start of my code, I no longer get the Document Inspector warning:
'Disable privacy settings warning
Application.DisplayAlerts = False
open the document > alt+f11 > Module Thisworbook input this:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Application.DisplayAlerts = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.DisplayAlerts = False
End Sub