如何将 MS Word 中带有 VBA 的部分文本移动到右侧?

How I can move part of text in MS Word with VBA to right side?

我需要编写将字符串分成两部分的宏。文本的一部分在 word 中左对齐,右对齐第二个。

我在本主题中找到了执行此操作的手动步骤,我的问题是如何自动执行此操作?

https://superuser.com/questions/484261/word-formatting-need-to-align-left-to-left-right-to-right-in-same-line

我尝试在 Word 中创建两个文本栏:

With ActiveDocument.PageSetup.TextColumns 
 .SetCount NumColumns:=2 
End With

但我不知道如何将我的部分文本放入所需的列中。谁能帮帮我?

尝试转到开发人员选项卡并单击 'Record Macro'。然后手动进行拆分。之后点击 'Stop Recording'。这将为您提供自动拆分文本所需的命令。

在 Constuntine 的帮助下,我找到了解决方案 - 在我想要拆分为左侧和右侧的每一行中,我执行以下操作:

With objWord
        .Visible = False
        .Selection.TypeParagraph
        .Selection.TypeText ("ABC" & vbTab & "123")
        .Selection.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(17), _
        Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
End With