Saving Word document with automatic Document Inspector


Office for Mere Mortals
Your beginners guide to the secrets of Microsoft Office
Invalid email address
Tips and help for Word, Excel, PowerPoint and Outlook from Microsoft Office experts.  Give it a try. You can unsubscribe at any time.  Office for Mere Mortals has been running for over 20 years, we've never, ever revealed or sold subscriber details.  Privacy policy

Here’s how to save a Word document with the private and hidden details automatically removed.

Normally, you’re expected to manually go to File | Info | Inspect document to check/remove things like comments, hidden text, header, footers or watermarks.

saving word document with automatic document inspector microsoft word 23799 - Saving Word document with automatic Document Inspector

What if you want it to happen automatically, whenever you save a file or just make it more accessible than clicking around the Backstage pane?

Inspect Document on the QAT

Buried on the long list of Quick Access Toolbar commands is Inspect Document.

Go to Customize Quick Access Toolbar, choose All Commands then scroll down to Inspect Document.

saving word document with automatic document inspector microsoft word 23800 - Saving Word document with automatic Document Inspector

Now just click the QAT button and Inspect Document appears.

saving word document with automatic document inspector microsoft word 23801 - Saving Word document with automatic Document Inspector

Fully Automating Inspect Document with Save

There’s no direct equivalent of Inspect Document in Word’s VBA but it’s possible to combine commands.  In fact, a VBA function gives you more options.

This custom function ends with a Save command.  Unlike the Inspect Document option which doesn’t save at the end.

It also changes some document properties or options that aren’t available on the ribbon.  These properties stop Word saving personal info or date/time in the document.

Sub InspectTheDocument()

' based on code from Bernadette at http://www.vbaexpress.com/forum/showthread.php?42228-Document-Inspect

Dim docStatus As MsoDocInspectorStatus

Dim results As String

Dim ComboResults As String

 

' Turn off Tracking and accept all changes.

Application.ActiveDocument.TrackRevisions = False

WordBasic.AcceptAllChangesInDoc

 

' Removes all document metadata and 'extras'

Application.ActiveDocument.RemoveDocumentInformation (wdRDIAll)

 

' OR be more selective with statements like

'Application.ActiveDocument.RemoveDocumentInformation (wdRDIComments)

'Application.ActiveDocument.RemoveDocumentInformation (wdRDIDocumentProperties)

' Application.ActiveDocument.RemoveDocumentInformation (wdRDIRemovePersonalInformation)

 

' These two lines change document properties so that

' Personal Info or Date/Time are not saved in future

Application.ActiveDocument.RemovePersonalInformation = True

 

Application.ActiveDocument.RemoveDateAndTime = True

 

' Collapsed Headings

ActiveDocument.DocumentInspectors(1).Fix docStatus, results

ComboResults = results

 

' Headers, Footers and Watermarks

ActiveDocument.DocumentInspectors(3).Fix docStatus, results

ComboResults = ComboResults & results

 

' Comment this out unless you want the interruption

MsgBox ("The following items were removed " & ComboResults)

' display on status bar

Application.StatusBar = "Removed:" & ComboResults

 

' save the document

ActiveDocument.Save

 

End Sub

 

.RemoveDocumentInformation parameters

The method Application.ActiveDocument.RemoveDocumentInformation () has many options or enumerations available.

Use Application.ActiveDocument.RemoveDocumentInformation (wdRDIAll) to remove all extra document info.

Or use a series of commands to select exactly what you want removed.

wdRDIAll
99        Removes all document information.

wdRDIComments
 1          Removes document comments.

wdRDIContentType
16        Removes content type information.

wdRDIDocumentManagementPolicy
 15        Removes document management policy information.

wdRDIDocumentProperties
8          Removes document properties.

wdRDIDocumentServerProperties
14        Removes document server properties.

wdRDIDocumentWorkspace
10        Removes document workspace information.

wdRDIEmailHeader
5          Removes e-mail header information.

wdRDIInkAnnotTations
11        Removes ink annotations.

wdRDIRemovePersonalInformation
4          Removes personal information.

wdRDIRevisions
2          Removes revision marks.

wdRDIRoutingSlip
6          Removes routing slip information.

wdRDISendForReview
7          Removes information stored when sending a document for review.

wdRDITemplate
9          Removes template information.

wdRDITaskpaneWebExtensions
17        Removes taskpane web extensions information.

wdRDIVersions
3          Removes document version information.

subs profile e1563205311409 - Saving Word document with automatic Document Inspector
Latest news & secrets of Microsoft Office

Microsoft Office experts give you tips and help for Word, Excel, PowerPoint and Outlook.

Give it a try. You can unsubscribe at any time.  Office Watch has been running for over 20 years, we've never, ever revealed or sold subscriber details.  Privacy policy
Invalid email address