A relatively frequent request we see in the Open XML SDK forum is how to make the [Compatibility Mode] text in the Word title bar disappear.

By default, the Open XML SDK will create a document compatible with Word 2007. When opened in a later version of Office, [Compatibility Mode] appears in the document title bar. The question is, how to make the document a Word 2010 or Word 2013 document.

The key lies in creating a Compatibility element in settings.xml that tells Word this document is a Word 2010 (or 2013) document. The critical nodes in the Word Open XML are:
<w:compat>
  <w:compatSetting w:val=”14″
                               w:uri=”http://schemas.microsoft.com/office/word
                               w:name=”compatibilityMode”/>
</w:compat>
Following is some C# code that generates the necessary settings part, settings content and compat and compatSetting elements for a Word 2010 document. For a Word 2013 document “val” should be set to “15”.

I’ll show the code for VB.NET in my next post, as there are some problems using the Linq approach that works for C#.
private static void AddSettingsToMainDocumentPart(MainDocumentPart part)
{
    DocumentSettingsPart settingsPart = part.DocumentSettingsPart;
    if (settingsPart==null)
        settingsPart = part.AddNewPart&lt;DocumentSettingsPart&gt;();
        settingsPart.Settings = new Settings(
          new Compatibility( 
            new CompatibilitySetting() { 
               Name = new EnumValue&lt;CompatSettingNameValues&gt;
                       (CompatSettingNameValues.CompatibilityMode),
               Val = new StringValue("14"),
               Uri = new StringValue
                       ("http://schemas.microsoft.com/office/word")
           }
       )
    );
    settingsPart.Settings.Save();
}
Leave a Reply

*