如何使用 powershell 在 Microsoft Word docx 文件中将文本方向设置为 RTL?

How can I set the text direction to RTL in Microsoft Word docx file using powershell?


我正在使用 powershell 创建一个 docx 文件。
我能够创建一个文件并设置样式、字体和对齐方式。
我的问题是将文本方向从默认 (LTR) 更改为 RTL。
这是我的工作代码:
$word = New-Object -ComObject Word.Application
$word.Visible = $false
$doc = $word.documents.add()

$selections = $word.Selection
$selections.Font.Name = "Arial"
$selections.Font.Size = 16
$selections.paragraphFormat.Alignment = 2
$selections.TypeText("Hello World!")

$out_path = ".\file.docx"
$doc.SaveAs($out_path)
$doc.Close()
$word.Quit()

我没有找到任何设置文字方向的信息。
我将不胜感激,
谢谢。

在你的程序中使用这个:

$doc = $word.documents.add()
$doc.Paragraphs.ReadingOrder = 0