Condividi tramite


Associating a Custom Document Information Panel with an Office Document

When a custom Document Information Panel is associated with an Office document and/or template, the information needed to locate the Panel is contained in a custom XML data part stored with the document.
I won’t go into the details of the way an Office Open XML document is structured here (needless to say there are many great resources for this on the web), but the format is basically a ZIP file with a collection of XML files that describe the contents of the word processing, spreadsheet, or presentation. Those XML files are linked to each other via logical “relationships” that define the necessary semantics (e.g. that one file contains the content for the header).

In the terms familiar to the Office Open specification, a custom XML data part is stored at the following location in an Office Open XML document:

Basically, the data is stored in an XML file which is logically related to the main part for that file type, and whose logical relationship is of type “customXml”.
Now then, the other half of the definition of a custom Document Information Panel is the content of that custom XML data part. Here’s an example of the data stored in the custom XML data part for a custom Document Information Panel:

<customPropertyEditors xmlns="http://schemas.microsoft.com/office/2006">
      <showOnOpen>
            true
      </showOnOpen>
      <defaultPropertyEditorNamespace>
            http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-21T21:12:27
      </defaultPropertyEditorNamespace>
      <customPropertyEditor>
            <XMLNamespace>
                    http://schemas.microsoft.com/office/infopath/2003/myXSD
            </XMLNamespace>
            <XSNLocation>
                    \contoso-serverformsassetForm.xsn
            </XSNLocation>
      </customPropertyEditor>
</customPropertyEditors>

This part defines the settings for the Document Information Panel by using the following four elements:

Element Name Definition
showOnOpen This element specifies whether the Document Information Panel should automatically be displayed when the document is opened and the first time it is saved.
defaultPropertyEditor This element specifies which Document Information Panel template should be shown first when the Panel is made visible (either automatically or by the user).

The contents of this element are one of two choices:• Standard properties – this setting shows the default Office 2007 property template• <custom XML namespace> - if the template to be shown should be a custom Document Information Panel stored with the document, its root XML namespace is stored in this element, so Office can locate and display this information automatically when the Document Information Panel is shown

XMLNamespace The root XML namespace of the custom Document Information Panel. If this template is the one which should be shown automatically, this value is the same as the value of the defaultPropertyEditor element.
XSNLocation The location of the InfoPath form template to be shown in the Document Information Panel. This location can be of either of the following forms:• File path to the InfoPath form template.• The URN of the form template if it is a template installed on the target computer.

With that information defined, Office automatically locates a custom Document Information Panel and displays it as requested. Note that none of these steps involve using Office to set up the Document Information Panel – this process can be automated without Office (for example, to add a Document Information Panel to a template as part of a server-based process).

Alnur Ali
Program Manager

Comments

  • Anonymous
    July 11, 2007
    Alnur, Do you whether you can show a modal dialog from a DIP or is this disabled? I am running a fully trusted form and the XDocument.UI.ShowModalDialog method returns an error from script. Pete.

  • Anonymous
    June 04, 2008
    When a custom Document Information Panel is associated with an Office document and/or template, the information needed to locate the Panel is contained in a custom XML data part stored with the document. I won’t go into the details of the way an Offic