none
Styles in use in an OOXML/Word document RRS feed

  • Question

  • Is there an easy way to determine whether a specific style is being used (applied to a paragraph) in an OOXML/Word document?  I've been looking for some kind of "flag" in the styles part, without success. I'd rather not have to examine each paragraph's actual style to see if it matches the one I'm intereste in.  Thanks.
    Tuesday, September 2, 2014 4:20 PM

Answers

  • Hello Ron,

    There are no attributes that indicate that a style is actually in use in a document. You can examine the list of style (ISO/IEC 29500-1:2012 §17.7.4.17) elements and potentially glean some knowledge about what styles the document is using. Styles actually used in the document will have an individual style element. Styles known to the application can be listed in lsdException (§17.7.4.8) elements of the latentStyles (§17.7.4.5) element, but their presence does not indicate their use in the document.

    It’s conceivable that an application could create a document that contains style elements for styles not actually in use. In addition, styles that are linked to other styles will also be included among these elements, even if they aren’t used directly, and styles that inherit from other styles (see the basedOn attribute in §17.7.4.3) will cause parent styles to be present despite the fact that they may not be referenced directly by a run. For example, if you have a run that is styled with the “Heading2” style, the document will contain style entries for both Heading2 and Heading2Char:

      <w:style w:type="paragraph" w:styleId="Heading2">
        ...
        <w:link w:val="Heading2Char"/>
        ...
      </w:style>

      <w:style w:type="character" w:customStyle="1" w:styleId="Heading2Char">
        ...
        <w:link w:val="Heading2"/>
        ...
      </w:style>

    If you need to know definitively what styles are applied to runs in the document then you’ll need to evaluate the style information associated with the runs themselves.

    Best regards,
    Matt Weber | Microsoft Open Specifications Team

    Tuesday, September 9, 2014 6:21 PM

All replies

  • Hi Ron,

    Thank you for your question. A member of the Protocol Documentation support team will respond to you soon.

    Regards,
    Vilmos Foltenyi - MSFT

    Tuesday, September 2, 2014 6:11 PM
  • Hello Ron,

    I'm currently looking into your question and should have an answer for you soon. Thank you for your patience.

    Best regards,
    Matt Weber | Microsoft Open Specifications Team

    Monday, September 8, 2014 9:25 PM
  • Hello Ron,

    There are no attributes that indicate that a style is actually in use in a document. You can examine the list of style (ISO/IEC 29500-1:2012 §17.7.4.17) elements and potentially glean some knowledge about what styles the document is using. Styles actually used in the document will have an individual style element. Styles known to the application can be listed in lsdException (§17.7.4.8) elements of the latentStyles (§17.7.4.5) element, but their presence does not indicate their use in the document.

    It’s conceivable that an application could create a document that contains style elements for styles not actually in use. In addition, styles that are linked to other styles will also be included among these elements, even if they aren’t used directly, and styles that inherit from other styles (see the basedOn attribute in §17.7.4.3) will cause parent styles to be present despite the fact that they may not be referenced directly by a run. For example, if you have a run that is styled with the “Heading2” style, the document will contain style entries for both Heading2 and Heading2Char:

      <w:style w:type="paragraph" w:styleId="Heading2">
        ...
        <w:link w:val="Heading2Char"/>
        ...
      </w:style>

      <w:style w:type="character" w:customStyle="1" w:styleId="Heading2Char">
        ...
        <w:link w:val="Heading2"/>
        ...
      </w:style>

    If you need to know definitively what styles are applied to runs in the document then you’ll need to evaluate the style information associated with the runs themselves.

    Best regards,
    Matt Weber | Microsoft Open Specifications Team

    Tuesday, September 9, 2014 6:21 PM
  • Hi Matt,

    Thanks for your response.  It wasn't answer I hoped for, of course, but that's life. The reason why I was hoping for something simpler is that I've seen a VBA macro that deletes all unused styles. I guess it looks at each run, as you suggest.

    Thanks, Gary

    Thursday, September 11, 2014 3:25 PM