简体   繁体   中英

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

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 administrate your own dictionary.

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 .

来自 Lene Fredborg 文档的屏幕截图

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM