Search code examples
openxmloleoffice-2007docxxlsx

Setting custom Open XML metadata


Background

Custom properties in Open XML are stored in docProps/custom.xml and look like this (for a string):

<property fmtid="{xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx}" pid="2" name="Key">
    <vt:lpwstr>Value</vt:lpwstr>
</property>

The Open XML (v1) specification doesn't give many details about fmtid and pid. It merely states in section 7.3.2.2:

[PID] Uniquely relates a custom property with an OLE property

Questions

I have a few questions about the specification's vague explanation:

  1. What are OLE properties?
  2. Is it possible add a new OpenXML property in custom.xml without storing an OLE property?
  3. Does pid need to be unique per fmtid, or unique for all fmtids in custom.xml
  4. Why don't my own properties in custom.xml appear in Word?

Solution

  • I'm going to partially answer my own question based on what I discovered by experimenting.

    1. OLE properties are NTFS extended attributes that are stored in alternative file streams. They can be viewed or modified with DSOfile.dll. See this StackOverflow question.

    2. Custom properties can be added by modifying custom.xml. They will only appear in Word's properties dialog if the fmtid belongs to Word or a loaded COM add-in.