Ali Ahmadi
Ali Ahmadi

Reputation: 2417

How can I set text direction RightToLeft in ms word document in c#?

I create a word document in c# with Microsoft.Office.Interop.Word

I want display my Arabic text in rtl(RightToLeft) direction. How can I set text direction to rtl ?

In my below code, I change Alighnment, But I can't change direction. Please Help me!

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();

Upvotes: 5

Views: 4252

Answers (2)

Ahmad
Ahmad

Reputation: 41

Try

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

where oDoc is a Word._Document instance

Upvotes: 4

Alexander Zbinden
Alexander Zbinden

Reputation: 2541

Did you try this?

wordParagraph.ReadingOrder = WdReadingOrder.wdReadingOrderRtl;

Upvotes: 5

Related Questions