22

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.

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
Tess in Oz
  • 251
  • 1
  • 2
  • 7

3 Answers3

25

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

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
  • 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 Apr 13 '18 at 04:04
  • @TessinOz Is it a mixture of Excel 2016 and 2013 or only 2016 and are you in a domain environment with Group Policies? – Vomit IT - Chunky Mess Style Apr 13 '18 at 04:09
3

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
Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
Tess in Oz
  • 251
  • 1
  • 2
  • 7
1

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