none
What locale is the default for a document, and how do I get it? RRS feed

  • Question

  • Hi all;

    We have an issue where we need to insert a table we create via Range.InsertXML() reversed if a document is defaulting to Arabic or Hebrew. What value should I read to determine if an inserted table needs to be reversed?

    And there are two issues we face here. First, how do we order the columns. Second, we need to have a forEach tag at the top of the first column in the docx file so we need to know which column will occur first in the docx file.

    thanks - dave


    Who will win The Windward International Collegiate Programming Championships?


    • Edited by DavidThi808 Thursday, February 7, 2013 1:18 AM
    Thursday, February 7, 2013 1:17 AM

Answers

  • Hi Dave

    <<I see that both the Normal style and the section (sectPr) have a <w:bidi/> element for a document created with Arabic as the default.>>

    What you have to watch out for is that the Normal style might not reflect the actual language formatting being used. The Windows language could override this, applying direct formatting to the text that will be the "default" for the document unless the user changes it. And if Word is configured to automatically recognize the language and change it according to what is typed, that can also apply direct language formatting.

    When you insert a table it will actually be linked to a paragraph, and a new table will generally take on the (language) formatting of a neighboring paragraph. So I think you'll be better off checking the text direction of the surrounding text (paragraph preceding where you use Tables.Add) than checking the Normal style...


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by DavidThi808 Thursday, February 7, 2013 5:57 PM
    Thursday, February 7, 2013 5:13 PM
    Moderator

All replies

  • I can't quite follow the whole question but that's due to local time; just discovered a Microsoft Express version (kinda offtopic here) and its stronger than me ;-)

    How to find the encoding for Arabic or Hebrew: ActiveDocument.SaveEncoding. You'll be checking for the consts msoEncodingArabic (there are more variants; ASMO, AutoDetect, etc. Check VB editor for more).

    And second; msoEncodingEBCDICHebrew

    Check for those (if ActiveDocument.SaveEncoding = msoEncodingEBCDICHebrew then ....).

    I'll think about the other issue tomorrow, in the mean time I hope thjis can help too.


    With kind regards, Peter

    Thursday, February 7, 2013 4:19 AM
  • Hi Dave

    If I'm not mistaken, a Word document can have mixed LTR/RTL content, so I'd think you'd want to check the Range or Selection where the table should be inserted, not the default for the document?

    Best would probably be the Paragraphs.ReadingOrder property which returns a Word.WdReadingOrder Enum.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, February 7, 2013 6:54 AM
    Moderator
  • Hi Shel;

    The SaveEncoding appears to be for HTML only.

    thanks - dave


    Who will win The Windward International Collegiate Programming Championships?

    Thursday, February 7, 2013 4:30 PM
  • Hi Cindy;

    Yeah, there is no specific default for the document (RTF did have that). We're inserting a table so we're not in any specific paragraph. And for what we do, we want to match the default locale of the document even though that is not a property.

    I see that both the Normal style and the section (sectPr) have a <w:bidi/> element for a document created with Arabic as the default. So I'm thinking I should use one of those. I'm going to try the Normal style as that holds document wide.

    If anyone knows how Word makes this decision, please sing out!!!

    thanks - dave


    Who will win The Windward International Collegiate Programming Championships?

    Thursday, February 7, 2013 4:36 PM
  • Hi Dave

    <<I see that both the Normal style and the section (sectPr) have a <w:bidi/> element for a document created with Arabic as the default.>>

    What you have to watch out for is that the Normal style might not reflect the actual language formatting being used. The Windows language could override this, applying direct formatting to the text that will be the "default" for the document unless the user changes it. And if Word is configured to automatically recognize the language and change it according to what is typed, that can also apply direct language formatting.

    When you insert a table it will actually be linked to a paragraph, and a new table will generally take on the (language) formatting of a neighboring paragraph. So I think you'll be better off checking the text direction of the surrounding text (paragraph preceding where you use Tables.Add) than checking the Normal style...


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by DavidThi808 Thursday, February 7, 2013 5:57 PM
    Thursday, February 7, 2013 5:13 PM
    Moderator
  • Ok, we'll try that and see what people say.

    thanks - dave


    Who will win The Windward International Collegiate Programming Championships?

    Thursday, February 7, 2013 5:57 PM