如何在VBA中段落的第一行之前添加空格?

问题描述 投票:0回答:2

我正在尝试在自动生成的Word文档中的一个段落之前添加空格。我只需要在该特定段落的第一行之前留出空格。问题是第一个空白行之后的下一行。

With Wapp
    With .Selection
        .TypeParagraph
        'Add line spacing
        .ParagraphFormat.SpaceBefore = 0
        .ParagraphFormat.SpaceAfter = 0
        .TypeText St1
        .TypeParagraph

        .ParagraphFormat.SpaceBefore = 36
        .BoldRun
        'Centers text
        .ParagraphFormat.Alignment = 1
        .TypeText St2
        .BoldRun
        .ParagraphFormat.SpaceBefore = 0

        .TypeText VBA.vbNewLine
        .TypeText St3
        .TypeText VBA.vbNewLine
        .ParagraphFormat.Alignment = 1
    End With
End With
vba word spacing paragraph
2个回答
0
投票
With Wapp
    With .Selection
        .TypeParagraph
        'Add line spacing
        .ParagraphFormat.SpaceBefore = 0
        .ParagraphFormat.SpaceAfter = 0
        .TypeText St1
        .TypeParagraph
        'Starts spacing
        .ParagraphFormat.SpaceBefore = 6
        .BoldRun
        'Centers text
        .ParagraphFormat.Alignment = 1
        .TypeText St2
        .BoldRun
        .TypeText VBA.vbNewLine
        'Ends spacing
        .ParagraphFormat.SpaceBefore = 0
        .TypeText St3
        .TypeText VBA.vbNewLine
        .ParagraphFormat.Alignment = 1
    End With
End With

0
投票

您可以使用以下行为当前段落创建1英寸(72点)的第一行缩进:

.ParagraphFormat.FirstLineIndent = Application.InchesToPoints(1)
© www.soinside.com 2019 - 2024. All rights reserved.