我试图以编程方式更改“不要在同一样式的段落之间添加空格”。为了解决这个问题,我录制了一个宏,在此期间,我打开了段落对话框(页面布局>段落),选中了复选框(不添加空格)和一个宏,在此期间我取消选中复选框(添加空格)。不会影响“不要在相同样式的段落之间添加空格”。 。 。他们有相同的代码:如何以编程方式更改“不要在相同样式的段落之间添加空格”?
Sub AddSpaceBetweenParagraphsOfSameStyle()
'
' AddSpaceBetweenParagraphsOfSameStyle Macro
' Add space between paragraphs of the same style.
'
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 12
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1)
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(-0.25)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
End With
End Sub
Sub RemoveSpaceBetweenParagraphsOfSameStyle()
'
' RemoveSpaceBetweenParagraphsOfSameStyle Macro
' Remove space between paragraphs of the same style.
'
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 12
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1)
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(-0.25)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
End With
End Sub
由宏录制生成的代码很长,所以我把它减少到我已经验证也没有影响“不要的段落之间添加空间的最小版本相同的风格“:
Sub AddSpaceBetweenParagraphsOfSameStyle()
'
' AddSpaceBetweenParagraphsOfSameStyle Macro
' Add space between paragraphs of the same style.
'
End Sub
Sub RemoveSpaceBetweenParagraphsOfSameStyle()
'
' RemoveSpaceBetweenParagraphsOfSameStyle Macro
' Remove space between paragraphs of the same style.
'
End Sub
我看着the documentation for ParagraphFormat和搜索相关的属性,但没有发现任何作品。如何以编程方式更改“不要在相同样式的段落之间添加空格”?
如果您发布您尝试的代码,我们可以帮助您更好地完成任务。 – RubberDuck
您可以通过阅读我的文章并使用宏记录器来生成我尝试过的代码,如前所述。 。 。但正如我所描述的那样,记录的代码遗漏了我想要做的事情,所以发布它将无济于事。 – Homer
嘿,我只是想帮你找到答案。 SO不是你的私人服务台。如果您提供[最小,完整和可验证示例](http://stackoverflow.com/help/mcve),则您更有可能收到及时,准确的答案。这表明你已经付出了努力。社区成员更可能帮助表现出努力的人。 – RubberDuck