Customizing the 2007 Office System Document Inspector

Summary: The Document Inspector enables you to quickly find and remove sensitive and hidden information in your documents. Learn how to create your own Document Inspector modules. (20 printed pages)

Frank Rice, Microsoft Corporation

Published: May 2006

Updated: November 2006

Applies to: 2007 Microsoft Office Suites, Microsoft Office Excel 2007, Microsoft Office PowerPoint 2007, Microsoft Office Word 2007

Contents

  • Introduction to the Document Inspector

  • What Is Personal Information?

  • Glossary for the Document Inspector

  • Scenarios Using the Document Inspector

  • Working with the Document Inspector

  • Changes to the 2007 Microsoft Office System Object Model

  • Displaying or Hiding Document Inspector Modules

  • Code Samples Using the Document Inspector

  • Creating a Custom Document Inspector Module

  • Conclusion

  • Additional Resources

Introduction to the Document Inspector

The Document Inspector provides a central location for you to examine documents for personal, hidden, or sensitive information. You can then use built-in Document Inspector modules to remove unwanted information more easily (see Figure 1). You can also create your own modules.

Figure 1. The Document Inspector user interface

The Document Inspector user interface

Note

Microsoft does not support automatically removing hidden information for signed or protected documents, or for documents using Information Rights Management (IRM). We recommend that you run the Document Inspector before signing or invoking IRM on these documents. It should also be noted that you can disable the Document Inspector by setting local policy on the user's computer.

NoteNote

Microsoft does not support automatically removing hidden information for signed or protected documents, or for documents using Information Rights Management (IRM). We recommend that you run the Document Inspector before signing or invoking IRM on these documents.

It should also be noted that you can disable the Document Inspector by setting local policy on the user's computer.

The Document Inspector framework enables you to deploy custom Document Inspector modules that you can integrate into the user interface. Document Inspectors are included in Microsoft Office Word 2007, Microsoft Office Excel 2007, and Microsoft Office PowerPoint 2007.

What Is Personal Information?

In documents, personal information is any information that identifies or can be used to identify, contact, or locate the person to whom such information pertains. This includes any information that is derived from a document, including, but not limited to, the following types of information:

  • Your name and initials

  • Your company or organization name

  • The name of your computer

  • The name of the network server or hard disk drive where you saved the document

  • Other file properties and summary information

  • Non-visible portions of embedded OLE objects

  • The names of previous document authors

  • Document revisions

  • Document versions

  • Template information

  • Hidden text

  • Tracked changes and comments

The availability of this information exposes the consumer to the potential for identity fraud, credit fraud, and other illegal activities. Even the United States Congress and the United States Federal Trade Commission are beginning to take action to protect the privacy of personal information.

Glossary for the Document Inspector

The following glossary defines terms used in this article and related content:

Personal information.   Any information gathered without the user's knowledge that identifies or can be used to identify, contact, or locate the author of the document.

Metadata.   Information about the document. For example, the creation date, revisions, author name, comments, and tracked changes.

Document Inspector.   A feature that helps you to examine and remove sensitive information in a document. The DocumentInspector object enables you to create custom modules.

Inspector Module.   A unit that is designed to identify and, optionally, remove specific types of metadata and other information in a document. There are built-in modules that are included with the application. You can also create custom modules.

Inspect.   To examine a document for specific types of information.

Fix.   To remove unwanted content and metadata from a document. This content is typically information added by the application that created the document.

Scenarios Using the Document Inspector

The following sections illustrate some possible scenarios for using the Document Inspector:

  • Melissa is an account representative for a public relations company. She opens a document announcing a client's new product, for final distribution. She wants to post the document online and send it to several news publications. Following corporate policy, she uses the Document Inspector to review the document contents and ensure that the file is safe to send. Melissa finds that the document contains some comments and revisions, and other hidden text. She also discovers that the document contains specific words that her company prohibits.

    First, Melissa removes the comments and revisions by opening the Document Inspector dialog box, and then selecting the Comments, Revisions, Versions, and Annotations option. She decides to keep some of the information because she is the author and is okay with being the primary contact of the document. Next, Melissa selects the Hidden Text option to remove all instances of the text that is difficult to find. After she has selected the options she wants, she clicks Inspect to begin the inspection process. When the process finishes, the Document Inspector dialog box tells her which types of information was found and gives her the option to remove that information.

    Melissa sees an option in the Document Inspector dialog box to search for specific words. This module, developed by her company, tells her that she used three words that are sensitive and not recommended. So Melissa searches the document, and finds the three words. She keeps two of the words, because they are quotes from individuals, and deletes the third word.

    Finally, Melissa closes the Document Inspector window, saves the document, and then prepares to distribute it.

  • Howard is a software developer for a law office that produces hundreds of documents per year. Frequently, these documents contain sensitive information about the client and the document. To protect against public disclosure of sensitive information, Howard wrote a module that uses the Document Inspector object model to inspect and remove certain information common to all documents produced by his company.

  • Janet is a loan officer at a small bank. Several times a day she attaches documents to e-mail messages. When she attempts to send a message with an attachment to an external recipient, her e-mail application notifies her that the attachment might contain sensitive information and should be reviewed before sending. Janet uses a third-party add-in Document Inspector module to locate and remove sensitive information. Her e-mail message passes through the firewall with no problems.

Working with the Document Inspector

The Document Inspector is composed of modules that users can use to inspect and fix specific portions of the document.

The Document Inspector in the 2007 Microsoft Office system includes specific built-in modules.

For Office Excel 2007:

  • Comments and Annotations

  • Document Properties and Personal Information

  • Custom XML Data

  • Headers and Footers

  • Hidden Rows and Columns

  • Hidden Worksheets

  • Invisible Content

For Office PowerPoint 2007:

  • Comments and Annotations

  • Document Properties and Personal Information

  • Custom XML Data

  • Invisible On-Slide Content

  • Off-Slide Content

  • Presentation Notes

For Office Word 2007:

  • Comments, Revisions, Versions, and Annotations

  • Document Properties and Personal Information

    This includes metadata, Microsoft SharePoint properties, custom properties, and other content information.

  • Custom XML Data

  • Headers, Footers, and Watermarks

  • Hidden Text

To open and perform an inspection with the Document Inspector

  1. Click the Microsoft Office Button and point to Prepare (see Figure 2).

    Figure 2. The Prepare menu option list

    The Prepare menu option list

  2. Click Inspect Document.

    The Document Inspector dialog box is displayed.

    NoteNote

    You can also invoke the Document Inspector from the Microsoft Office Button. To do so, click Word Options, click the Trust Center tab, click Trust Center Settings, click Privacy Options, and then click Document Inspector.

  3. If you have not already done so, you are prompted to save the document. Click Yes. The Document Inspector screen is displayed.

  4. Select the modules corresponding to the types of content you want to search for, and then click Inspect.

    After the inspection is finished, the Document Inspector dialog box shows which modules found content in the document. It also provides buttons to remove that content, as shown in Figure 3.

    Figure 3. The Document Inspector dialog box showing the results of an inspection

    The Document Inspector dialog box

    The Inspect button also changes to Reinspect. If you click the Reinspect button at this point, the Document Inspector screen is re-displayed, enabling you to choose additional modules for inspection.

    If the user chooses to remove the data for the module, the descriptive text for each module indicates whether the operation was successful, as shown in Figure 4.

    Figure 4. The Document Inspector dialog box after fixing the document

    Document Inspector dialog box after document fixes

    If the Document Inspector encounters errors during the operation, the module is flagged and displays an error message. The data for that module does not change.

  5. To select other modules for inspection, click Reinspect. Otherwise, click Close.

    NoteNote

    Some of the built-in modules, such as the Custom XML Data module, interact with the Properties pane such that data is removed from the pane. In Word, when you choose a module that interacts with the Properties pane, the pane is closed. However, the Properties pane is not closed in Office Excel 2007 and Office PowerPoint 2007.

Changes to the 2007 Microsoft Office System Object Model

You can create Document Inspector modules in managed code and unmanaged code. To implement the Document Inspector programmatically in unmanaged code in Microsoft Visual Basic for Applications (VBA), the 2007 Microsoft Office system adds a new DocumentInspectors collection type to the object models in Office Excel 2007, Office PowerPoint 2007, and Office Word 2007. The DocumentInspectors collection is part of the Document object in Word, the Workbook object in Excel, and the Presentation object in PowerPoint. A DocumentInspectors collection contains multiple DocumentInspector objects, one for each module.

Table 1. Properties of the DocumentInspectors collection

Type

Name

Property

Application (read-only)

Property

Count (read-only)

Property

Creator (read-only)

Property

Item (read-only)

Property

Parent (read-only)

Table 2. Methods, properties, and enumerations of the DocumentInspector object

Type

Name

Property

Application (read-only)

Property

Creator (read-only)

Property

Description (read-only)

Property

Name (read-only)

Property

Parent (read-only)

Method

Inspect(MsoDocInspectorStatus As MspDocInspectorStatus, Results As String)

Method

Fix(MsoDocInspectorStatus As MspDocInspectorStatus, Results As String)

Enumeration

enum MsoDocInspectorStatus

msoDocInspectorStatusDocOk,

msoDocInspectorStatusError,

msoDocInspectorStatusIssueFound

There is also an IDocumentInspector interface for creating Document Inspector modules in managed code. The IDocumentInspector interface includes the methods shown in Table 3.

Table 3. Methods of the IDocumentInspector interface

Type

Signature (Visual Basic .NET)

Method

Fix(document as Object, hwnd as Long, status as MsoDocInspectorStatus, result as String)

Method

GetInfo(name as String, description as String)

Method

Inspect(document as Object, status as MsoDocInspectorStatus, result as String, action as String)

Displaying or Hiding Document Inspector Modules

Entries in the registry provide the list of Document Inspector modules displayed in the Document Inspector dialog box. This includes the built-in modules and any custom modules. To remove a Document Inspector module from appearing in the list, you must delete the registry key for that module.

Important noteImportant

This article contains information that may require that you modify the registry. Before modifying the registry, make a backup copy of it. Also, be sure that you know how to restore the registry if a problem occurs. For more information about how to back up, restore, and modify the registry, see Description of the Microsoft Windows registry.

The following registry keys are written when an individual Document Inspector module loads:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Excel\Document Inspectors
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\PowerPoint\Document Inspectors

Each key contains subkeys, such as:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors\Comments And Revisions
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors\Custom XML
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors\Document Properties and Personal Information
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors\Headers and Footers
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors\Hidden Text

The key name for custom modules can be anything that is meaningful to the user.

Subkeys specify the following values:

  • Name: CLSID

  • Type: REG_SZ

The CLSID value is required. It must refer to a class ID (CLSID) that is present in the HKEY_CLASSES_ROOT folder in the Windows registry, which is the GUID for the Document Inspector module you are using.

  • Name: Selected

  • Type: REG_DWORD

  • Data: 0x00000001(1)

Setting the value of this key to 1 ensures that the option is selected by default when the Document Inspector dialog box is displayed.

Code Samples Using the Document Inspector

The following syntax and samples illustrate working with the Document Inspector with VBA.

Calling the Inspect Method

Syntax

object.Inspect(Status As MsoDocInspectorStatus, Results As String)

Sample

Public Sub InspectDocument()
   Dim docStatus As MsoDocInspectorStatus
   Dim results As String
   ActiveDocument.DocumentInspectors(1).Inspect(docStatus, results)
End Sub

Calling the Fix Method

Syntax

object.Fix(Status As MspDocInspectorStatus, Results As String)

Sample

Public Sub FixDocument()
Dim docStatus As MsoDocInspectorStatus
Dim results As String
ActiveDocument.DocumentInspectors(1).Fix(docStatus, results)
End Sub

Displaying the Document Inspector Dialog Box

Sample

Public Sub ShowDocumentInspector()
   Dim oWord As Word.Application
   Set oWord = CreateObject("Word.Application")
   oWord.Dialogs.Item(wdDialogDocumentInspector).Show
End Sub

Using a Document Inspectors Property

Syntax

Property Count As Long (read-only)

Sample

Public Sub CountDocInspectorModules()
   MsgBox("There are " & ActiveDocument.DocumentInspectors.Count & " Document Inspector modules in this document.")
End Sub
NoteNote

The Comments and Revisions built-in module and the Document Information built-in module are not exposed in the DocumentInspectors object. This means that a count of DocumentInspector items does not include these two modules, even though they appear in the Document Inspector dialog box. Additionally, the Inspect method and the Fix method for these modules are not available in the object model. Instead, you can use the RemoveDocumentInformation method to remove this type of information.

Using the RemoveDocumentInformation Method

The RemoveDocumentInformation method has several options for removing personal or sensitive information from your document.

Syntax

object.RemoveDocumentInformation(RemoveDocInfoType As WdRemoveDocInfoType)

Where WdRemoveDocInfoType can be one of the following enumerations:

  • wdRDIComments = 1

  • wdRDIRevisions = 2

  • wdRDIVersions = 3

  • wdRDIRemovePersonalInformation = 4

  • wdRDIEmailHeader = 5

  • wdRDIRoutingSlip = 6

  • wdRDISendForReview = 7

  • wdRDIDocumentProperties = 8

  • wdRDITemplate = 9

  • wdRDIDocumentWorkspace = 10

  • wdRDIInkAnnotations = 11

  • wdRDIDocumentServerProperties = 14

  • wdRDIDocumentManagementPolicy = 15

  • wdRDIContentType = 16

  • wdRDIAll = 99

Sample

Sub RemoveDocumentInfoandPII()
   ActiveDocument.RemoveDocumentInformation wdRemovePersonalInformation
End Sub

Using the IDocumentInspector Interface

Syntax

Microsoft.Office.Core.IDocumentInspector.Fix(doc As Object, Hwnd As Long, status As MsoDocInspectorStatus, result As String)
void Microsoft.Office.Core.IDocumentInspector.Fix(object doc, long hwnd, out Microsoft.Office.Core.MsoDocInspectorStatus status, out string 
result)

Where:

  • doc represents the Word document.

  • hwnd is the value for the window hosting the document.

  • status is an enumeration indicating whether words were found or if there was an error.

  • result is the text that is displayed below the option in the Document Inspector dialog box.

Sample

void Microsoft.Office.Core.IDocumentInspector.Fix(object doc, long hwnd, out Microsoft.Office.Core.MsoDocInspectorStatus status, out string 
result)
{
   /*The FixWordDocument procedure is explained in more detail
   later in this article.*/
   this.FixWordDocument((Word._Document)doc, out status, out result); 
}

Syntax

Microsoft.Office.Core.IDocumentInspector.GetInfo(name As String, desc As String)
void Microsoft.Office.Core.IDocumentInspector.GetInfo(out string name, out string desc)

Where:

  • name is the name of module. This is displayed in the Document Inspector dialog box.

  • desc is a description of the purpose of the module. This is displayed in the Document Inspector dialog box.

Sample

void Microsoft.Office.Core.IDocumentInspector.GetInfo(out string name, out string description)
{
   name = "My Custom Module"
   description = "This name and description appear in the Document Inspector dialog box."
}

Syntax

Microsoft.Office.Core.IDocumentInspector.Inspect(doc As Object, status As MsoDocInspectorStatus, result As String, action As String)
void Microsoft.Office.Core.IDocumentInspector.Inspect(object doc, out Microsoft.Office.Core.MsoDocInspectorStatus status, out string result, 
out string action)

Where:

  • doc represents the Word document.

  • status is an enumeration indicating whether words were found or if there was an error.

  • result is the text that is displayed below the option in the Document Inspector dialog box.

  • action is the text that is displayed to the right of the module option in the Document Inspector dialog box.

Sample

void Microsoft.Office.Core.IDocumentInspector.Inspect(object document, out Microsoft.Office.Core.MsoDocInspectorStatus status, out string 
result, out string action)
{
   /*The InspectWordDocument procedure is explained in more detail
   later in this article.*/
   this.InspectWordDocument((Word._Document)doc, out status, out result);
}

Creating a Custom Document Inspector Module

As stated earlier, you can create Document Inspector modules in managed code or unmanaged code. You can create an unmanaged custom Document Inspector module by using VBA. You can create a managed custom Document Inspector module as a Microsoft Visual Studio 2005 project by using one of the .NET languages, such as Microsoft Visual Basic .NET or Microsoft Visual C#.

Creating a Document Inspector Module to Remove and Replace Specific Words

In this example, you create a custom Document Inspector module in a Visual Studio 2005 project as a shared add-in. The module searches a document for specific words and replaces them with alternate words of your choice. The search words and replacement words are stored in an array, but you could also store them in an .xml file and import the file into the project as an embedded resource.

The add-in that Visual Studio 2005 creates is a Microsoft .NET assembly with the extension .dll. Although it is not a COM DLL, Visual Studio 2005 adds enough information to mimic a COM add-in when it installs the add-in.

To create the project

  1. On the File menu, click New Project.

  2. In the New Project dialog box, under Project Types, click Other Project Types, and then click Extensibility.

  3. In the Templates pane, click Shared Add-In.

  4. Type SearchReplaceKeyword in the Name box, and then click OK.

  5. In the Shared Add-in Wizard, click Next, and then on the Select a Programming Language panel, select Create an Add-in using Visual C#.

  6. On the Select an Application Host page, clear all of the check boxes except Microsoft Word, and then click Next.

  7. On the Enter a Name and Description page, type Search & Replace for the name of the add-in. This name is displayed on the Add-Ins tab of the Word Options dialog box.

  8. Add a short description, and then click Next.

  9. In the Choose Add-In Options panel, select the I would like my Add-in to load when the host application loads check box, and then click Next.

  10. Click Finish to create the add-in.

Adding Code to the Add-In

To make the add-in actually do something, you need to add code to the methods implemented as part of the IDocumentInspector interface and to any supporting procedures. However, you first need to add references from the project to the required type libraries.

In these steps, you create a reference to the Microsoft Office 2007 object library and to the primary interop assembly for Office Word 2007. Adding a reference to the 2007 Office object library gives you access to the Office (in this case, Word-specific) COM object model members from the project. The Word primary interop assembly provides the bridge between the Word object model and the .NET Framework.

To add references to the project

  1. In Solution Explorer, right-click the References node, and then click Add Reference.

  2. In the Add Reference dialog box, click the .NET tab.

  3. Scroll and select Microsoft.Office.Interop.Word, as shown in Figure 5.

    Figure 5. Adding a reference to the Word primary interop assembly

    Adding a reference to the Word PIA

  4. Click the COM tab, scroll to Microsoft Office 12.0 Object Library, select it, and then click OK.

    The new references appear under the References node in Solution Explorer.

  5. In Solution Explorer, right-click Connect.cs, and then click View Code.

  6. Below the namespace SearchReplaceKeyword statement, add the following statements:

       using System;
       using Extensibility;
       using System.Runtime.InteropServices;
       using MSO = Microsoft.Office.Core;
       using Word = Microsoft.Office.Interop.Word;
       using System.Data;
       using System.Collections;
       using System.IO;
       using System.Text;
       using System.Windows.Forms;
    

    These statements provide access to the objects and classes in the various namespaces defined in the Common Language Runtime.

    Now add the IDocumentInspector interface to the project.

  7. At the end of the public class Connect: Object statement, type a comma and MSO.IDocumentInspector.

    Next, as with any interface, you need to implement each of its members, regardless of whether you add code to them. In this project, you use all three methods.

  8. Click to select IDocumentInspector, right-click, point to Implement Interface, and then click Implement Interface Explicitly.

    This action creates three stub procedures, one for each of the members of the interface.

  9. Immediately below the opening brace ({) of the public class Connect: statement, add the following statements:

    private string[] badTerms = new string[] { "always", "never", "must" };
    private string[] goodTerms = new string[] { "most of the time", "not likely", "should" };
    

    These statements declare and populate two arrays with the "good" and "bad" words.

  10. Replace the statements in the OnConnection method with the following:

    applicationObject = (Word.Application)application;
    addInInstance = addInInst;
    MessageBox.Show("Document Inspector add-in is loading");
    

    The first two statements create an object that points to the instance of Word when you start that program. The message is displayed when the add-in loads into Word. This gives you a visual indicator that the add-in loaded. This is primarily for your benefit while debugging the project and should be removed before deployment.

  11. Locate and replace the private Application applicationObject; statement with the following statement:

    private Word.Application applicationObject;
    
  12. Replace the code in the Fix method you created earlier with the following statements:

    MessageBox.Show("Fixing document");
    this.FixWordDocument((Word._Document)Doc, out Status, out Result);
    

    This message gives you a visual indication that something is happening when you initiate fixing the document. The other statement calls the FixWordDocument method, which you will see shortly.

  13. Replace the code in the GetInfo method with the following:

    name = "Keyword Replacer";
    desc = "Replaces bad terms with acceptable terms.";
    

    This is the name and description text, respectively, that will appear by the option for this module in the Document Inspector dialog box.

  14. Replace the code in the Inspect method with the following:

    MessageBox.Show("Inspecting document");
    ArrayList itemsFound = null;
    
    itemsFound = this.InspectWordDocument((Word._Document)doc);
    if (itemsFound.Count > 0)
    {
       action = "Remove Items";
       status = MSO.MsoDocInspectorStatus.msoDocInspectorStatusIssueFound;
       result = "Items found";
    }
    Else
    {
       action = "No Items to Remove";
       status = MSO.MsoDocInspectorStatus.msoDocInspectorStatusDocOk;
       result = "No Items found";
    }
    

    This procedure first calls the InspectWordDocument method, which returns an array with any "bad" words found in the document. Then, if target words were found, the appropriate values are assigned to the action, status, and result variables. Action text appears to the right of the module text in the Document Inspector dialog box; status indicates whether words were found; result text is displayed under the module name in the Document Inspector dialog box.

  15. Next, add the InspectWordDocument procedure to the project:

    public ArrayList InspectWordDocument(Word._Document mydoc)
    {
       ArrayList itemsFound = new ArrayList();
       object find = null;
       object match = false;
       object missing = Type.Missing;
       foreach (string singleBadTerm in this.badTerms)
       {
          find = singleBadTerm;
    
          if(mydoc.StoryRanges[Word.WdStoryType.wdMainTextStory].Find.Execute(ref find, ref match, ref missing, ref missing, ref missing, ref 
    missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing))
          {
             itemsFound.Add(singleBadTerm);
          }
       }
       return itemsFound;
    }
    

    This procedure loops through the array of bad terms and checks the document to see if any of the terms are present, and, if so, adds the terms to a list. After there are no more search words, the list of found terms is returned to the Inspect method.

  16. Add the FixWordDocument procedure to the project:

    public void FixWordDocument(Word._Document mydoc, out MSO.MsoDocInspectorStatus status, out string result)
    {
       object find = null;
       object matchCase = false;
       object matchWord = true;
       object replaceWith = null;
       object matchWholeWord = false;
       object replace = Word.WdReplace.wdReplaceAll;
       object missing = Type.Missing; 
       int i = 0;
       foreach (string singleBadTerm in this.badTerms)
       {
          find = singleBadTerm;
          replaceWith = this.goodTerms[i];
          mydoc.StoryRanges[Word.WdStoryType.wdMainTextStory].Find.Execute(ref find, ref matchCase, ref matchWholeWord, ref missing, ref missing, 
    ref missing, ref missing, ref missing, ref missing, ref replaceWith, ref replace, ref missing, ref missing, ref missing, ref missing);
          i++;
       }
       status = MSO.MsoDocInspectorStatus.msoDocInspectorStatusDocOk;
       result = "All designated words have been replaced.";
    }
    

    This procedure loops through the array of terms and checks the document to see whether bad terms are present and, if so, replaces them with terms from the other array. The StoryRanges collection contains the individual occurrences of a particular term.

    Now you are ready to see the project in action.

To build and test the add-in

  1. On the File menu, select Save All to save the project.

  2. On the Build menu, click Build Solution.

  3. In Solution Explorer, right-click SearchReplaceKeywordSetup, and then click Build.

  4. Click Install. Follow the instructions in the installation wizard. The code automatically adds a key for the add-in to the registry at this location:

    HKey_Local_Machine\SOFTWARE\Microsoft\Office\12.0\Word\Document Inspectors

  5. On the File menu, click Save All, close the project, and then close Visual Studio.

  6. Start Office Word 2007. You should see the message Document Inspector add-in is loading.

  7. Close the message box.

  8. Type or paste the following text into the document:

    Always and never are two words you must always remember never to use.

    - Wendell Johnson

  9. On the File menu, point to Prepare, and then click Inspect Document.

  10. In the Document Inspector dialog box, you should see an option titled Keyword Replacer, as shown in Figure 6.

    Figure 6. The Document Inspector dialog box with the Keyword Replacer module

    Dialog box with the Keyword Replacer module

    If you do not see the Keyword Replacer option, the Shared Add-in Wizard may not have registered the add-in properly. In this case, you can manually register it by using the Regasm.exe tool provided by the Microsoft .NET Framework version 2.0 SDK.

    To manually register the add-in

    1. Close Word.

    2. In Windows Explorer, navigate to the following folder:

      path to project\SearchReplaceKeyword\bin\Debug

    3. Open a command prompt: Click Start, point to All Programs, point to Accessories, and then click Command Prompt.

    4. Type the following in a Command Prompt window:

      "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm"

      "SearchReplaceKeyword.dll"

      You should see a message that the type was registered successfully.

    5. Close the Command Prompt window.

  11. To test the add-in, clear all of the options except the Keyword Replacer check box, and then click Inspect.

    If the inspection finds instances of the specified terms, the Document Inspector displays them below the Keyword Replacer option when it refreshes the Document Inspector dialog box. It also displays a button that gives you the option to replace those terms, as seen in Figure 7.

    Figure 7. The results of a document inspection for the Keyword Replacer module

    The results of a document inspection

  12. To replace the keywords in the document, click Remove Items in the Document Inspector dialog box. The document is changed, as shown in Figure 8.

    Figure 8. The results of replacing keywords with the Keyword Replacer module

    The results of replacing keywords

Conclusion

The Document Inspector gives users a central location to discover what metadata or hidden information there is in their documents. From there, users can choose what action to take to protect or remove the information. Developers and corporations can create and deploy modules that use the Document Inspector object model to inspect and remove certain types of information. With more documents available on the Internet and being sent in e-mail messages, it is more important than ever for users and companies to be aware of, and manage, the sensitive information that may exist in their documents.

Additional Resources

The following resources provide additional information: