VBA Word 格式化 Selection.typetext

Sha*_*ker 5 formatting vba ms-word

我仍然是这个的初学者。你能告诉我为什么这不是格式化选择吗?

Selection.TypeText "title"

With Selection

        .Font.Bold = True
        .Font.Name = "Arial"
        .Font.ColorIndex = wdDarkBlue
        .ParagraphFormat.Alignment = wdAlignParagraphCenter
        .ParagraphFormat.SpaceAfter = 0
End With
Run Code Online (Sandbox Code Playgroud)

Oll*_*ren 5

它确实格式化文本,但仅在命令添加文本With Selection

更改顺序,放在Selection.TypeText "title"最后,它会起作用。:)