deku
deku

Reputation: 105

Enumerate localized style names from docx document

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)?

Upvotes: 1

Views: 112

Answers (2)

NineBerry
NineBerry

Reputation: 28499

The localization is part of the Word Executable.

See Word Vba : how to get the name of a style in foreign language on how to get the localized name from Office automation. If you want to go without Office automation, you'll have to keep your own dictionary.

Upvotes: 1

Charles Kenyon
Charles Kenyon

Reputation: 1028

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.

Upvotes: 2

Related Questions