How to Inspect Document in macro WITH custom Inspect options

Deborah 1 Reputation point
2021-11-16T16:22:36.563+00:00

I would like to inspect a document in a macro with custom inspect options. For example, our default has everything checked but Ink. I want Ink checked, and I want Headers/Footers/Watermarks and Hidden Text UNchecked. I have a macro, and hidden text doesn't seem affected, but removing the code that tells it to check Headers/Footers/Watermarks does not uncheck the option. I need something that's going to tell it to check everything BUT Headers/Footers/Watermarks and Hidden Text.

Sub InspectTheDocument()
'
' InspectTheDocument Macro
'
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
'
Application.ActiveDocument.RemoveDocumentInformation (wdRDIComments) 'Comments, Revisions, and Versions - COMMENTS
Application.ActiveDocument.RemoveDocumentInformation (wdRDIRevisions) 'Comments, Revisions, and Versions - REVISIONS
Application.ActiveDocument.RemoveDocumentInformation (wdRDIVersions) 'Comments, Revisions, and Versions - VERSIONS
Application.ActiveDocument.RemoveDocumentInformation (wdRDIDocumentProperties) 'Document Properties and Personal Information - DOCUMENT PROPERTIES
Application.ActiveDocument.RemoveDocumentInformation (wdRDIRemovePersonalInformation) 'Document Properties and Personal Information - PERSONAL INFORMATION
Application.ActiveDocument.RemoveDocumentInformation (wdRDITaskpaneWebExtensions) 'Task Pane Add-ins
Application.ActiveDocument.RemoveDocumentInformation (wdRDIContentType) 'Removes content type information (Embedded Documents)
Application.ActiveDocument.RemoveDocumentInformation (wdRDITemplate) 'Macros, Forms, and ActiveX Controls
Application.ActiveDocument.RemoveDocumentInformation (wdRDIInkAnnotations) 'Ink
' Custom XML Data
Application.ActiveDocument.RemoveDocumentInformation (wdRDIDocumentManagementPolicy) 'Removes document management policy information
Application.ActiveDocument.RemoveDocumentInformation (wdRDIDocumentServerProperties) 'Removes document server properties
' Headers, Footers, and Watermarks omitted from this code

' Invisible Content
Application.ActiveDocument.RemoveDocumentInformation (wdRDIEmailHeader) 'Removes e-mail header information
Application.ActiveDocument.RemoveDocumentInformation (wdRDIRoutingSlip) 'Removes routing slip information
Application.ActiveDocument.RemoveDocumentInformation (wdRDISendForReview) 'Removes information stored when sending a document for review
Application.ActiveDocument.RemoveDocumentInformation (wdRDIAtMentions) ' Unsure
'Collapsed Headings
ActiveDocument.DocumentInspectors(1).Fix docStatus, results
ComboResults = results
' Personal info or date/time are not saved in future
Application.ActiveDocument.RemovePersonalInformation = True
'Save the document
ActiveDocument.Save
'
End Sub
Microsoft 365 and Office Word For business Windows
Developer technologies Visual Basic for Applications
{count} votes

2 answers

Sort by: Most helpful
  1. John Korchok 6,126 Reputation points
    2021-11-16T17:54:27.667+00:00

    The original macro from Office Watch is for automating the inspection process, not for setting the options in the Inspector dialog. Once you have manually set the dialog options once, Word should remember your choices and automatically apply them when you run the macro.

    The original macro wasn't well written, so here it is made more efficient:

        Sub InspectTheDocument()
            Dim docStatus As MsoDocInspectorStatus
            Dim ComboResults As String
    
            ' Turn off tracking and accept all changes
            With ActiveDocument
                .TrackRevisions = False
                .Revisions.AcceptAll
    
                .RemoveDocumentInformation (wdRDIComments) 'Comments, Revisions, and Versions - COMMENTS
                .RemoveDocumentInformation (wdRDIRevisions) 'Comments, Revisions, and Versions - REVISIONS
                .RemoveDocumentInformation (wdRDIVersions) 'Comments, Revisions, and Versions - VERSIONS
                .RemoveDocumentInformation (wdRDIDocumentProperties) 'Document Properties and Personal Information - DOCUMENT PROPERTIES
                .RemoveDocumentInformation (wdRDIRemovePersonalInformation) 'Document Properties and Personal Information - PERSONAL INFORMATION
                .RemoveDocumentInformation (wdRDITaskpaneWebExtensions) 'Task Pane Add-ins
                .RemoveDocumentInformation (wdRDIContentType) 'Removes content type information (Embedded Documents)
                .RemoveDocumentInformation (wdRDITemplate) 'Macros, Forms, and ActiveX Controls
                .RemoveDocumentInformation (wdRDIInkAnnotations) 'Ink
            ' Custom XML Data
                .RemoveDocumentInformation (wdRDIDocumentManagementPolicy) 'Removes document management policy information
                .RemoveDocumentInformation (wdRDIDocumentServerProperties) 'Removes document server properties
            ' Headers, Footers, and Watermarks omitted from this code
    
            ' Invisible Content
                .RemoveDocumentInformation (wdRDIEmailHeader) 'Removes e-mail header information
                .RemoveDocumentInformation (wdRDIRoutingSlip) 'Removes routing slip information
                .RemoveDocumentInformation (wdRDISendForReview) 'Removes information stored when sending a document for review
                .RemoveDocumentInformation (wdRDIAtMentions) ' Unsure
            'Collapsed Headings
                .DocumentInspectors(1).Fix docStatus, ComboResults
                MsgBox "Status: " & docStatus & "   Results: " & ComboResults
            ' Personal info or date/time are not saved in future
                .RemovePersonalInformation = True
            'Save the document
                .Save
            End With
        End Sub
    
    0 comments No comments

  2. Deborah 1 Reputation point
    2021-11-16T18:04:25.627+00:00

    Unfortunately, our Word is set so that it defaults back to everything checked but Ink once you close Word. Does anyone else know a way to do this with custom Inspect options?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.