如何在c#中的ms word文档中设置文本方向RightToLeft?

时间:2012-06-28 09:37:30

标签: c# ms-word

我使用Microsoft.Office.Interop.Word

在c#中创建一个word文档

我希望在rtl(RightToLeft)方向显示我的阿拉伯文字。如何将文本方向设置为rtl?

在我的下面的代码中,我改变了Alighnment,但我无法改变方向。请帮帮我!

Word.Application wordApp = new Word.Application();
object objMissing = System.Reflection.Missing.Value;
Word.Document wordDoc = wordApp.Documents.Add(ref objMissing, ref objMissing, ref objMissing, ref objMissing);
Word.Paragraph wordParagraph = wordDoc.Paragraphs.Add(ref objMissing);
wordParagraph.Range.Font.Name = "B Titr";
wordParagraph.Range.Font.Size = 14;
WordParagraph.Range.ParagraphFormat.Alignment =  Word.WdParagraphAlignment.wdAlignParagraphRight;
wordParagraph.Range.Text = "My Arabic text";
wordParagraph.Range.InsertParagraphAfter();

2 个答案:

答案 0 :(得分:4)

你试过这个吗?

wordParagraph.ReadingOrder = WdReadingOrder.wdReadingOrderRtl;

答案 1 :(得分:4)

尝试

oDoc.Paragraphs.ReadingOrder = Word.WdReadingOrder.wdReadingOrderRtl;

其中oDocWord._Document个实例