帮我写一段VBA代码用以调整word中的字体以及段落格式。要求:1、根据不同的大纲级别设置不同的格式。所有级别大纲均为段前段后0磅。2、一级大纲设置为宋体居中14号大小加粗行距为单倍行距。二级大纲设置为宋体左对齐12号大小加粗行距为单倍行距。三级大纲设置为宋体左对齐11号大小行距为单倍行距首行缩进074厘米。四级大纲设置为宋体左对齐11号大小行距为单倍行距首行缩进074厘米。
Sub AdjustFormat() Dim doc As Document Set doc = ActiveDocument
'设置一级大纲格式
With doc.Styles(wdStyleOutline1)
.Font.Name = "宋体"
.Font.Size = 14
.Font.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
.ParagraphFormat.SpaceBefore = 0
.ParagraphFormat.SpaceAfter = 0
End With
'设置二级大纲格式
With doc.Styles(wdStyleOutline2)
.Font.Name = "宋体"
.Font.Size = 12
.Font.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
.ParagraphFormat.SpaceBefore = 0
.ParagraphFormat.SpaceAfter = 0
End With
'设置三级大纲格式
With doc.Styles(wdStyleOutline3)
.Font.Name = "宋体"
.Font.Size = 11
.Font.Bold = False
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
.ParagraphFormat.SpaceBefore = 0
.ParagraphFormat.SpaceAfter = 0
.ParagraphFormat.FirstLineIndent = CentimetersToPoints(0.74)
End With
'设置四级大纲格式
With doc.Styles(wdStyleOutline4)
.Font.Name = "宋体"
.Font.Size = 11
.Font.Bold = False
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
.ParagraphFormat.SpaceBefore = 0
.ParagraphFormat.SpaceAfter = 0
.ParagraphFormat.FirstLineIndent = CentimetersToPoints(0.74)
End With
End Su
原文地址: https://www.cveoy.top/t/topic/fYT5 著作权归作者所有。请勿转载和采集!