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

Document Inspector error

Be careful! Parts of your document may include personal information that can't be removed by the Document Inspector.

3 Answers 3


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.



  • 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.


  • Hi, that's great for one file but I've got 82 of them and would like to avoid opening each one. I tried recording your solution as a macro but it failed. Is there a VB solution?
    – Tess in Oz
    Commented Apr 13, 2018 at 4:04
  • @TessinOz Is it a mixture of Excel 2016 and 2013 or only 2016 and are you in a domain environment with Group Policies? Commented Apr 13, 2018 at 4:09

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
  • 2
    This does not work in every case. Commented Mar 14, 2019 at 15:16
  • @Tess - You should accept this answer here you wrote by turning the check mark green since it resolved your problem. Commented May 5, 2020 at 2:53

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .