公文标题的排版,先设置一个样式,我选择将word内置的“标题”样式进行修改。代码如下:
Sub 标题一()
'标题一:黑体 三号字
With ActiveDocument.Styles("标题").Font
.NameFarEast = "黑体"
'西文字体
.NameAscii = "Times New Roman"
.NameOther = "Times New Roman"
.Name = "Times New Roman"
.Size = 16
End With
With ActiveDocument.Styles("标题").ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing = 28.8
.CharacterUnitFirstLineIndent = 2
.CharacterUnitRightIndent = 0
.AutoAdjustRightIndent = True
.Alignment = wdAlignParagraphLeft '左对齐
'段前短后0磅
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
End With
ActiveDocument.Styles("标题").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("标题")
.AutomaticallyUpdate = False
.BaseStyle = "正文"
.NextParagraphStyle = "标题"
End With
End Sub
Sub 标题二()
'标题二:楷体三号字
With ActiveDocument.Styles("标题").Font
.NameFarEast = "楷体"
.NameAscii = "Times New Roman"
.NameOther = "Times New Roman"
.Name = "Times New Roman"
.Size = 16
End With
With ActiveDocument.Styles("标题").ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing = 28.8
.CharacterUnitFirstLineIndent = 2
.CharacterUnitRightIndent = 0
.AutoAdjustRightIndent = True
.Alignment = wdAlignParagraphLeft '左对齐
'段前短后0磅
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
End With
ActiveDocument.Styles("标题").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("标题")
.AutomaticallyUpdate = False
.BaseStyle = "正文"
.NextParagraphStyle = "标题"
End With
End Sub
Sub 标题三()
'标题三:仿宋三号
With ActiveDocument.Styles("标题").Font
.NameFarEast = "仿宋_GB2312"
.NameAscii = "Times New Roman"
.NameOther = "Times New Roman"
.Name = "Times New Roman"
.Size = 16
End With
With ActiveDocument.Styles("标题").ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing = 28.8
.CharacterUnitFirstLineIndent = 2
.CharacterUnitRightIndent = 0
.AutoAdjustRightIndent = True
.Alignment = wdAlignParagraphLeft '左对齐
'段前短后0磅
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
End With
ActiveDocument.Styles("标题").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("标题")
.AutomaticallyUpdate = False
.BaseStyle = "正文"
.NextParagraphStyle = "标题"
End With
End Sub