Enumerate localized style names from docx document

Viewed 27

I want to get a list of styles from docx (without opening Word).

It's not a problem using WordPorcessingDocument. Sample code on this page.

But in styles.xml file inside docx are only english names of styles. In Polish language style "heading 1" is "Nagłówek 1".

Definition of "heading 1" looks like this:

<w:style w:type="paragraph" w:styleId="Nagwek1">
    <w:name w:val="heading 1"/>
    <w:basedOn w:val="Normalny"/>
    <w:next w:val="Normalny"/>
    <w:link w:val="Nagwek1Znak"/>
    <w:uiPriority w:val="9"/>
    <w:qFormat/>
    <w:rsid w:val="0029243B"/>
    <w:pPr>
        <w:spacing w:before="240"/>
        <w:jc w:val="center"/>
        <w:outlineLvl w:val="0"/>
    </w:pPr>
    <w:rPr>
        <w:rFonts w:cs="Arial"/>
        <w:b/>
        <w:bCs/>
        <w:caps/>
    </w:rPr>
</w:style>

Nowhere isn't using name "Nagłówek 1" in any file in docx.

Is it translate inside Word engine? Is it possible to get polish name of "heading 1" (without creating own dictionary)?

2 Answers

You can use the string or numeric constants for built-in styles.

You can get a complete list using the macro-enabled document prepared by Word MVP Lene Fredborg.

screenshot from Lene Fredborg's document

There are 375 built-in styles. Most of these are Table styles. The document should give you local names as well when you run the macro. The macro is not hidden and can be examined. It works based on your language settings for your Normal template.

Related