Office Development

Manage Metadata with Document Information Panels

Ashish Ghoda

This article discusses:

  • Document Information Panels
  • Maintaining metadata
  • Using InfoPath forms
This article uses the following technologies:
2007Office System, .NET Framework 3.5

Code download available at:DocumentInformationPanel2008_04.exe(205 KB)

Contents

Metadata Management with Document Information Panels
Document Properties Management
Custom Document Properties Management
The InfoPath Form Template
Show or Hide Document Information Panel
Insert Checklist Quick Parts
Binding
Integrating Document Information Panel with the Document
Version Issues
Wrapping It Up

These days, every organization faces tough information management challenges. With critical information stored in disparate locations in a wide variety of formats, making the data easy to find and consume can be tricky. In addition to simply enabling discoverability and consumption of data, companies must also have policies in place for data retention and government compliance.

To meet these emerging needs and implement information-driven applications, documents must be appropriately attributed with metadata and that metadata should be made available across all systems in the enterprise. In this article I'll demonstrate how to enable effective metadata and content management using the Document Information Panel, a form-based component within Microsoft® Word 2007, Excel® 2007, and PowerPoint® 2007 that allows users to manage document-level metadata.

Metadata Management with Document Information Panels

The Microsoft Office platform always allowed you to maintain both standard and custom properties for documents. Document Information Panels, however, let you implement additional functionalities such as metadata-based search and automation of information-driven business processes. With Document Information Panels, users can implement as document-specific metadata on the following four types of document properties: core or standard properties, custom document properties, content types for Microsoft Office SharePoint® Server (MOSS) 2007, and extended and advanced custom properties. Let's look at each.

Core Properties Users can manage core document properties common to all Office documents—Author, Title, Subject, Keywords, Category, Status, and Comments—using the standard Document Properties view of the Document Information Panel.

Custom Document Properties To add further business context to Office documents, the 2007 Microsoft Office system allows you to attach a trusted custom InfoPath® form templates as a custom Document Information Panel. Figure 1 shows an InfoPath form template that I've called ChecklistMetadata—I'll walk through this with you later. It is attached as a custom Document Information Panel to a Word 2007 document.

Figure 1 InfoPath Form Template Attached to a Word 2007 Document

Figure 1** InfoPath Form Template Attached to a Word 2007 Document**
(Click the image for a larger view)

Content Types for SharePoint Server 2007 Documents stored in MOSS 2007 document libraries contain custom document properties that are mapped to content types defined for the associated SharePoint site. These documents will automatically display the content type's fields as custom Document Information Panels. Users can update the content type field values in the offline/online mode and they will automatically be saved back to the document library when the user is connected.

For more information on the custom Document Information Panel for MOSS 2007-based documents, you can go to go.microsoft.com/fwlink/?LinkId=109825.

Extended and Advanced Custom Properties Users can access and manage additional document-specific custom properties by accessing the document properties window through the Document Information Panel's Advanced Properties option, as shown in Figure 2. From this dialog, users can populate Extended Properties using the Summary tab and create new custom properties using the Custom tab. For even richer metadata management capabilities, the Document Information Panel can be configured to allow for the display and management of document metadata via InfoPath forms.

Figure 2 Advanced Properties Menu

Figure 2** Advanced Properties Menu **(Click the image for a larger view)

The Developer tab in the 2007 Office system lets you customize documents using code, controls, customized XML, and templates—it is also where the Document Information Panel can be enabled. Figure 3 shows the highlighted Document Panel option for a Word 2007 document. To display and configure the Document Information Panel within an Office 2007 document, click on the Document Panel option.

Figure 3 Document Panel Option for a Word 2007 Document

Figure 3** Document Panel Option for a Word 2007 Document **(Click the image for a larger view)

If you want to attach a custom Document Information Panel, specify a custom template using the network path or URL of the InfoPath form template. Note that you do not need to specify a custom template at this point if you just want to view the standard document properties.

Next, select the Standard Properties or Custom Properties option (only if a custom InfoPath form template is attached) to use as "Display by Default" for the Document Information Panel. When multiple views are available in the InfoPath form template, the default view will be displayed as the custom Document Information Panel with access to other views.

One of the key requirements for efficient metadata management is to have a consistent metadata schema across applications. The Document Information Panel facilitates this consistency and reuse—the same InfoPath 2007 template can also be attached as a custom Document Information Panel to Word, Excel, and PowerPoint 2007 documents.

As you probably know, the 2007 Office system documents are based on the Open XML format. As a result, they consist of a .zip file package containing XML files that hold content and metadata related to the document. As such, document properties are stored as XML inside of the package. Since all this information is stored as XML, it is quite simple to access it programmatically in order to automate metadata-driven business processes. I'll explain how that works in the following sections.

Document Properties Management

Standard document properties can be maintained through the Document Properties view of the Document Information Panel. To see where these properties are actually stored in the OpenXML package, open the .rels file in the _rels folder of the unzipped Office document. As you can see in Figure 4, this file shows that standard document properties (core properties) are stored in the core.xml file within the docProps folder. The core.xml file contains all of the standard document properties that are populated from the Document Properties view in the Document Information Panel.

Figure 4 A Relationship File

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships
   xmlns="https://schemas.openxmlformats.org/package/2006/relationships">
  <Relationship Id="rId3" 
    Type="https://schemas.openxmlformats.org/officeDocument/2006/
    relationships/extended-properties" Target="docProps/app.xml"/>
  <Relationship Id="rId2" 
    Type="https://schemas.openxmlformats.org/package/2006/
    relationships/metadata/core-properties" Target="docProps/core.xml"/>
  <Relationship Id="rId1"
    Type="https://schemas.openxmlformats.org/officeDocument/2006/
    relationships/officeDocument" Target="word/document.xml"/>
  <Relationship Id="rId4" 
    Type="https://schemas.openxmlformats.org/officeDocument/2006/
    relationships/custom-properties" Target="docProps/custom.xml"/>
</Relationships>

The code in Figure 5 demonstrates how to get a standard document property value and set it to a new value using the Word object model's DocumentProperties object. The BuiltInDocumentProperties property of the Word document object returns a DocumentProperties object that is a collection of standard DocumentProperty objects. The Item property is then used to retrieve a specific DocumentProperty object by specifying a property name (in this case, the category property). The Value property of the DocumentProperty object is used to set or get the value of the property.

Figure 5 Get a Standard Document Property

Dim StandardProperties As Microsoft.Office.Core.DocumentProperties
Dim StandardProperty As Microsoft.Office.Core.DocumentProperty

Dim Category As String

'Assign Current Document Standard Properties
StandardProperties = _
  DirectCast(Globals.ThisDocument.BuiltInDocumentProperties, _
  Microsoft.Office.Core.DocumentProperties)

'Assign "category" property
StandardProperty = StandardProperties.Item("category")

'Get "category" property value
Category = StandardProperty.Value

'Set "category" property value to "Modified Checklist"
StandardProperty.Value = "Modified Checklist"

With the Word object model, you can also use the CustomXMLParts object to access these properties as XML files (see Figure 6). The CustomXMLParts object returns a collection of CustomXMLPart objects which contain the XML files that describe the document. The first XML file in the collection is the core.xml file, which contains the standard document properties. Once you have obtained a reference to the XMLDocument object, you can use XPath query methods such as SelectSingleNode to manipulate nodes such as the category property node.

Figure 6 Access Properties as XML

Dim OfficeCustomXMLParts As Microsoft.Office.Core.CustomXMLParts
Dim Category As String

'Assign CustomXMLParts containing standard/core 
'document properties XML Part
OfficeCustomXMLParts = DirectCast(Globals.ThisDocument.CustomXMLParts, _
  Microsoft.Office.Core.CustomXMLParts)

'Find the "category" property node and get the value of "category"
 'standard property

Category = OfficeCustomXMLParts.Item(1).SelectSingleNode _
 ("//*[local-name(.)='category']").Text

'Find the "category" property node and set the value of "category"
' standard property
OfficeCustomXMLParts.Item(1).SelectSingleNode _
 ("//*[local-name(.)='category']").Text = "modified category"

Custom Document Properties Management

Custom document properties can be maintained via an InfoPath form template that is attached as a custom Document Information Panel. The InfoPath form data is stored inside of the document as a custom XML document part. Note that relationships for all custom XML Parts included in the document are defined in the document.xml.rels file within the Word/_rels folder. The custom XML files themselves are found in the customXml folder. Each custom XML document part has its own relationship definition file, which is stored in the customXml/_rels subfolder. As shown below, the item1.xml part has a corresponding item1.xml.rels file, which points to the itemProps1.xml file and specifies that this XML part holds custom properties describing item1.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Relationships
  xmlns="https://schemas.openxmlformats.org/package/2006/relationships">
  <Relationship Id="rId1"
    Type="https://schemas.openxmlformats.org/officeDocument/2006/
    relationships/customXmlProps" Target="itemProps1.xml" />
</Relationships>

The itemProps1.xml file then indicates through schema reference that the custom XML Schema is an InfoPath schema. This enables Word to open item1.xml as an InfoPath form:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ds:datastoreItem ds:itemID="{A9851B97-75EE-4C97-ACC6-D9EB7DA1D3DC}"
  xmlns:ds="https://schemas.openxmlformats.org/officeDocument/
  2006/customXml">
  <ds:schemaRefs>
    <ds:schemaRef ds:uri="https://schemas.microsoft.com/office/
      infopath/2003/myXSD/2007-09-01T16:03:56" />
    <ds:schemaRef ds:uri="https://schemas.microsoft.com/
      office/infopath/2003" />
  </ds:schemaRefs>
</ds:datastoreItem>

In order to specify that custom XML properties should be attached as a custom Document Information Panel, simply indicate this relationship through a schema reference:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ds:datastoreItem ds:itemID="{B97FA79B-5941-4441-9A4B-3E001C0278D6}"
   xmlns:ds="https://schemas.openxmlformats.org/officeDocument/2006/
  customXml">
  <ds:schemaRefs>
    <ds:schemaRef ds:uri="https://schemas.microsoft.com/office/2006/
    customDocumentInformationPanel" />
  </ds:schemaRefs>
</ds:datastoreItem>

Now if I open this item, it indicates that InfoPath is used as a custom XML property editor and my ChecklistMetadata.xsn file is attached as an InfoPath form template to the custom Document Information Panel. To access the attached InfoPath form XML file, I can use the CustomXMLParts object as I have used to access standard document properties.

The code below demonstrates use of the CustomXMLParts object and the SelectSingleNode method to retrieve the InfoPath form field ProjectName node of the CL—Business—Information Technology category checklist:

Dim InfoPathXML As XmlDocument = New XmlDocument()
Dim projectname As String

'Load InfoPath Form XML
InfoPathXML.LoadXml(Globals.ThisDocument.CustomXMLParts.Item(4).XML)

'Get the "Project Name" field value of the 
'   CL - Business - Information Technology checklist metadata
projectname = InfoPathXML.SelectSingleNode _
 ("//*[local-name(.)='ProjectName']").InnerText

Additional custom properties can be maintained through the Advanced Properties view within the Document Information Panel. You can see where these properties are stored within the document package by looking at the .rels file within the root _rels folder. As you'll see, the relationship file indicates that custom document properties are stored in a file named custom.xml within the docProps folder.

For demonstration purposes I have added Client as a custom property to the document using the Advanced Properties dialog. As shown in the following code, the Client property is stored as follows in the docProps/custom.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Properties xmlns="https://schemas.openxmlformats.org/
  officeDocument/2006/
  custom-properties"
  xmlns:vt="https://schemas.openxmlformats.org/officeDocument/2006/
  docPropsVTypes">
  <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" 
    pid="2" name="Client">
    <vt:lpwstr>
      Client Value
    </vt:lpwstr>
  </property>
</Properties>

The code in Figure 7 demonstrates how to programmatically get Client custom property value and set it to a new value using the Word object model. As shown, the CustomDocumentProperties property of the Word Document object returns a collection of custom DocumentProperty objects. The Item property can then be used to retrieve a specific DocumentProperty object by specifying property name (in this case, Client). The Value property of the DocumentProperty object is used to set or get the value of a custom document property.

Figure 7 Get Client Custom Property

Dim CustomProperties As Microsoft.Office.Core.DocumentProperties
Dim CustomProperty As Microsoft.Office.Core.DocumentProperty
Dim client As String

'Assign Current Document Standard Properties
CustomProperties = DirectCast(Globals.ThisDocument.CustomDocumentProperties, Microsoft.Office.Core.DocumentProperties)

'Assign "client" property
CustomProperty = CustomProperties.Item("Client")

'Get "client" property value
client = CustomProperty.Value

'Set "client" property value to "Microsoft"
CustomProperty.Value = "Microsoft"

The following code demonstrates how to add a new custom property, Checklistversion, and set the value to 1:

Dim CustomProperties As Microsoft.Office.Core.DocumentProperties

'Assign Current Document Standard Properties
CustomProperties = _
  DirectCast(Globals.ThisDocument.CustomDocumentProperties, _
  Microsoft.Office.Core.DocumentProperties)

'Add "ChecklistVersion" as a custom property and set value to "1.1"
CustomProperties.Add("ChecklistVersion", False, _
  Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeNumber, "1.1").

As you can see, the Add method of the CustomDocumentProperties object is used both to add the new custom document property and to set its value to 1.1. And while the value is added as a string, the msoPropertyTypeNumber specifies that the string should be considered to be a number.

So far, it is clear that the Document Information Panel allows users and system administrators to manage and maintain metadata more effectively by storing it within an OpenXML document package, but as a separate document part within that package. However, efficient metadata-driven business process implementation is only possible when the metadata values can be used to automate business processes, control the content environment, and help users to automate the generation of repeatable content.

Next, I'll develop a Checklist management application based in Word 2007 to demonstrate how you can automate business processes by associating standard document properties and InfoPath form-based custom fields with other Word 2007 components like Content Controls, Quick Parts/Building Blocks, and customized fluent Ribbon controls.

To automate checklist management using Word 2007, I first must develop and publish an InfoPath form template, ChecklistMetadata.xsn, representing checklist metadata to attach as a Custom Document Information Panel to the Word 2007 document. Then I created a Word 2007 Document Project in Visual Studio® and attach the ChecklistMetadata.xsn form template as Custom Document Information Panel. Next, I created a Custom Ribbon control that will be used to show and hide the Document Information Panel.

I then developed a Word 2007 template, ChecklistsQuickPartsTemplate.dotm, containing different checklists as categorized custom Quick Parts and distribute to the user's application data folder to integrate with Word 2007 documents. Then I can implement a Custom Ribbon control to insert checklists Quick Parts programmatically as building blocks to the document from the attached ChecklistsQuickPartsTemplate.dotm template. Insert the checklist Quick Parts based on the checklist category selected in the custom Document Information Panel

Following that, I programmatically bound in standard document properties and InfoPath form fields (displayed using a custom Document Information Panel) to the document itself using Word 2007 content controls. Now I'll show you how users can manually add standard and extended document properties as Quick Parts to the document.

The InfoPath Form Template

Every checklist can have common and checklist-specific metadata. The InfoPath form template I am going to develop defines a sample generic and checklist-specific metadata.

First, I define the following checklist categories in the InfoPath form template at design time. They are shown in Figure 8. For illustration purposes, I have defined only two types of main categories: Business and Personal. I have also defined and developed metadata sections for the two categories: Business—Information Technology and Personal—Hospital categories.

Figure 8 Sample Checklist Categories

Figure 8** Sample Checklist Categories **(Click the image for a larger view)

The metadata added for the Business—Information Technology category includes Project Name, Purpose, and Team Members (all as multi-line textboxes, as you see in Figure 9). Project Number and Technology Used (as single-line textboxes), and Start and End Date as date pickers. Similarly, Figure 10 shows how the metadata is displayed for the Personal—Hospital category.

Figure 9 Business—Information Technology Metadata

Figure 9** Business—Information Technology Metadata **(Click the image for a larger view)

Figure 10 Personal—Hospital Metadata

Figure 10** Personal—Hospital Metadata **(Click the image for a larger view)

Based on the selection of the metadata category, the related metadata section will be displayed. This functionality is enabled utilizing InfoPath's conditional formatting functionality for each category section. For security reasons, the InfoPath form template must be published or installed to a local intranet or a trusted site before it can be attached to a document as a custom Document Information Panel.

Before publishing the InfoPath form template, set up proper security settings using Tools | Form Options | Security and Trust option (Figure 11). Once the template is published to a trusted location, attach it as custom Document Information Panel.

Figure 11 Security and Trust Settings

Figure 11** Security and Trust Settings **(Click the image for a larger view)

To maintain a high level of security, digitally sign the InfoPath form template using a certificate provided by an official third-party certificate provider and publish it to a trusted location such as a MOSS document library or Forms Server.

While you are in the development phase, it can be less cumbersome to sign your InfoPath form template using a self-signed certificate and publish it to the local machine. More information on this process is available at go.microsoft.com/fwlink/?LinkId=109827.

After you have created the InfoPath form template, create a new Word 2007 Document project in Visual Studio 2008. At design time, attach the ChecklistMetadata.xsn file as a custom Document Information Panel to the document, and select custom view as the default view. The InfoPath form view, Checklist Metadata, should be displayed as a custom Document Information Panel in the document.

You can confirm that the InfoPath form template is working by changing checklist category to CL—Business—Information Technology and CL—Personal—Hospital. You should see appropriate metadata section displayed within the Document Information Panel.

Show or Hide Document Information Panel

In order to gain more real estate on the monitor while you are working on the document, it is sometimes preferable to hide the Document Information Panel. The Office object model allows programmatic control over the visibility of the Document Information Panel, and I'll show you how to show or hide it by creating a customized ribbon control.

Add a ribbon to the project by selecting the Ribbon (Visual Designer) option from the new item dialog. Name the ribbon CustomizeChecklistRibbon. Add a button control named ShowHideDIP, which you will use to show or hide the Document Information Panel (see Figure 12).

Figure 12 Show or Hide Document Information Panel

Figure 12** Show or Hide Document Information Panel **(Click the image for a larger view)

The following code demonstrates how to show or hide the Document Information Panel programmatically. Add this code inside click event handler of the ShowHideDIP button:

'Check if Document Information Panel is visible
If Globals.ThisDocument.Application _
  .DisplayDocumentInformationPanel = True Then
  'Hide Document Information Panel
  Globals.ThisDocument.Application. _
  DisplayDocumentInformationPanel = False
Else
  'Show Document Information Panel 
  Globals.ThisDocument.Application. _
  DisplayDocumentInformationPanel = True
End If

The DisplayDocumentInformationPanel property of the Word Application object gets or sets a Boolean value used to control the display of the Document Information Panel.

Insert Checklist Quick Parts

Metadata-based content reusability is one of the key requirements for effective task automation. The Word 2007 Quick Parts feature allows users to identify reusable content sections for a document, categorize those content sections, and add them as Quick Parts to either the default Microsoft building blocks template or a custom Quick Parts template. Once the content is added as a Quick Part and copied to the AppData folder on a user's machine, the user has access to the reusable content for any Word 2007 document.

To insert checklist Quick Parts specific to the selected category in the custom Document Information Panel, retrieve the ChCategory InfoPath form XML field from the click event of the "Insert Checklist" ribbon control (Figure 3) by calling this method:

Function GetChecklistCategoryInfoPathField() As String
  Dim InfoPathXML As XmlDocument = New XmlDocument()
  Dim ChecklistCategory As String
    InfoPathXML.LoadXml(Globals.ThisDocument.CustomXMLParts.Item(4).XML)
    ChecklistCategory = InfoPathXML.SelectSingleNode( _ 
      "//*[local-name(.)='ChCategory']").InnerText
  Return ChecklistCategory
End Function

The Checklist InfoPath XML, attached as a custom Document Information Panel, is the fourth file in the CustomXMLParts collection and is retrieved using the Item property of the CustomXMLParts object. I load the InfoPath XML into a new XmlDocument object and query the document for the selected ChCategory node.

The method shown in Figure 13 filters the checklist Quick Parts from the Checklist Quick Parts template based on the selected checklist category. All remaining checklist Quick Parts are then inserted into the document with each Quick Part starting on a new page.

Figure 13 InsertChecklistQuickPartsAsBuildingBlock

Sub InsertChecklistQuickPartsAsBuildingBlock(ByVal _
  ChecklistCategory As String)

  'Declaration
  Dim oAttachedTemplate As Microsoft.Office.Interop.Word.Template
  Dim oBuildingBlock As Microsoft.Office.Interop.Word.BuildingBlock
  Dim selection As Microsoft.Office.Interop.Word.Selection
  Dim TotalQuickParts As Integer
  Dim iIndex As Integer

  'Define Attached Template - ChecklistsQuickPartsTemplate.dotm
  oAttachedTemplate = Globals.ThisDocument.AttachedTemplate

  'Get Total Number of quick parts available in the selected checklist
  ' category in the InfoPath form
  TotalQuickParts = oAttachedTemplate.BuildingBlockTypes _
    .Item(Word.WdBuildingBlockTypes.wdTypeQuickParts) _
    .Categories.Item("CL - " + ChecklistCategory) _
    .BuildingBlocks.Count

  selection = Globals.ThisDocument.Application.Selection

  'Insert all quick parts available in the defined category
  'Each quick part starts with a new page
  For iIndex = 1 To TotalQuickParts

    'Add Building Block Content Control
    selection.Range.ContentControls.Add(Word.WdContentControlType _
      .wdContentControlBuildingBlockGallery)

    'Define Quick Part as Building Block
    oBuildingBlock = oAttachedTemplate.BuildingBlockTypes _
      .Item(Word.WdBuildingBlockTypes.wdTypeQuickParts) _
      .Categories.Item("CL - " + ChecklistCategory) _
      .BuildingBlocks.Item(iIndex)

    'Insert Quick Part
    oBuildingBlock.Insert(selection.Range)

    selection.EndKey(Word.WdUnits.wdStory)
    selection.TypeParagraph()

    'No new page required if it is a last Quick Part
    If Not iIndex = TotalQuickParts Then
      selection.InsertBreak(Type:=Word.WdBreakType.wdPageBreak)
    End If

  Next

End Sub

After the code retrieves the template associated with the document (ChecklistQuickPartsTemplate.dotm, in this example), it proceeds to filter the template's BuildingBlock objects by the building block type (WdBuildingBlockTypes.wdTypeQuickParts) and by the user-selected category. Finally, it iterates through the filtered Quick Parts and inserts each checklist Quick Part into the document as a Content Control. You'll notice that the Selection object is used to define the insertion point in the active Word 2007 document.

Next, the code must insert a Page Break into the document before inserting the next checklist quick part. The InsertBreak method of the Selection object inserts a page, column, or section break into the Word document. The WdBreakType.wdPageBreak enumeration specifies that the break is a page break.

Binding

Since InfoPath form fields and document properties are defined and stored as custom XML files, you can bind the information available in the Document Information Panel to Content Controls within the document. The following code shows how to bind a Content Control to the ProjectName InfoPath form field populated within the custom Document Information Panel:

'Sample code to bind first content control to InfoPath 
'Form Field ProjectName
Globals.ThisDocument.ContentControls(1).XMLMapping.SetMapping _
  ("//*[local-name(.)='ProjectName']", , _
  Globals.ThisDocument.CustomXMLParts.Item(4))

The XMLMapping object represents a mapping between a Word 2007 content control and an XML node—the SetMapping method of the XMLMapping object establishes this mapping. I have identified the node ProjectName of the custom XML file using an XPath expression. The Checklist InfoPath form XML file is retrieved utilizing the document object's CustomXMLParts collection.

The following demonstrates how to bind a Content Control to the category standard document property:

'Sample code to bind first content control to a standard document 
'property - category       
Globals.ThisDocument.ContentControls(2).XMLMapping.SetMapping _
  ("//*[local-name(.)='category']", ,  _
  Globals.ThisDocument.CustomXMLParts.Item(1))

The only difference between this code and the code to map the content control with the InfoPath form field is the change in the XPath expression and the change in the index used to retrieve the document part from the CustomXMLParts collection.

Figure 14 shows how the Content Control binds to the InfoPath form field related to ProjectName checklist metadata and then it binds to the Category document standard property. As you can see, mapped property values are automatically populated in Content Controls.

Figure 14 Content Control Bound to InfoPath Form Field

Figure 14** Content Control Bound to InfoPath Form Field **(Click the image for a larger view)

Integrating Document Information Panel with the Document

It is possible to integrate standard and extended document properties as Quick Parts within the document. As you know, the standard document properties can be managed in the Standard Properties view of the Document Information Panel and extended document properties can be accessed using the Advanced Document Properties Management window through the Document Information Panel.

As shown in Figure 15, navigate to the Insert tab and click on the Quick Parts option. The Document Property option enables users to insert standard and extended document properties. In the figure, the Author standard document property is added as a Quick Part to the document. The inserted Quick Part is tightly integrated with the document property. In my example, if you change the value of the Author property within the Document Information Panel or within the document Quick Part, the modified value will automatically be reflected and the document property will be changed.

Figure 15 Author Standard Document Property Added as a Quick Part

Figure 15** Author Standard Document Property Added as a Quick Part **(Click the image for a larger view)

Version Issues

The 2007 Office system product suites allow opening and saving documents in the compatibility mode so that users with earlier versions of Office (Office 97-Office 2003) can open and work on documents. Obviously the features that are not supported in the previous versions of the Office products will not be supported in my solution here. Let's see what that means.

The Document Information Panel displays the standard document properties and custom document properties. All functionalities related to the standard and custom Document Information Panel views will work if a document is stored in compatibility mode and only when you are using a 2007 Office system application to work on the document.

However, once you use an earlier version of Office to open and save the document, the custom Document Information Panel will be detached from the document along with its related functions. The corresponding information will not be available to the users even if at a later time the document is opened again using Office 2007.

The good news is standard document properties will be preserved as-is, even if the 2007 Office system document saved in compatibility mode is opened and saved using an earlier version of Office. If the document is opened using Office 97-Office 2003, the user can access the standard document properties through the Document Properties Management dialog. If the user opens a document using the 2007 Office system, the standard document properties can be accessed through the Document Information Panel. All of the changes made to the standard properties will be retained in cross-version scenarios.

If the option "Always show Document Information Panel on document open and initial save" is checked to make the Document Information Panel always visible, that information will not be retained once the document is saved in the compatibility mode and is opened and saved using an earlier version of Office. In this case, the Document Information Panel will not be visible by default upon opening the document using Office, after first being saved in the earlier version.

If any document properties are bound to content controls within the document, upon saving a Word 2007 document in compatible mode, all Content Controls will be converted to the static text and will cease to be mapped to the document properties.

Wrapping It Up

The effective use of the standard and custom Document Information Panels can facilitate efficient metadata management and allow building efficient content management applications in conjunction with the Quick Parts and Content Controls. The value of using these technologies is standardized, structured metadata across the 2007 versions of Word, Excel, and PowerPoint. The more widely you employ this feature, the easier it will be to search your content and drive businesses processes using it.

If you have questions regarding this Document Information Panel feature, feel free to e-mail me at AskAshish@technologyopinion.com. And remember, all code for this project is available on the MSDN® Magazine Web site.

Ashish Ghoda is a technical manager at a big-four accounting firm. He's a Microsoft Certified Professional and Microsoft Certified Application Developer in .NET. He also manages the Web site technologyopinion.com and writes development articles. You can contact him at AskAshish@technologyopinion.com.