我试图在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
发布于 2019-09-25 19:52:23
交换了两行代码
.TypeText VBA.vbNewLine
和
.ParagraphFormat.SpaceBefore = 0
似乎将.ParagraphFormat放在.TypeParagraph或VBA.vbNewLine之后很重要,然后它就开始像我想要的那样工作了。
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
https://stackoverflow.com/questions/58096604
复制相似问题