Sub 宏12() With Selection.ParagraphFormat .LeftIndent = CentimetersToPoints(0.18) .RightIndent = CentimetersToPoints(0.18) .SpaceBefore = 5 .SpaceBeforeAuto = False .SpaceAfter = 5 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceDouble .Alignment = wdAlignParagraphJustify .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = CentimetersToPoints(0.35) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 1 .CharacterUnitRightIndent = 1 .CharacterUnitFirstLineIndent = 2 .LineUnitBefore = 1 .LineUnitAfter = 1 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False .AutoAdjustRightIndent = True .DisableLineHeightGrid = False .FarEastLineBreakControl = True .WordWrap = True .HangingPunctuation = True .HalfWidthPunctuationOnTopOfLine = False .AddSpaceBetweenFarEastAndAlpha = True .AddSpaceBetweenFarEastAndDigit = True .BaseLineAlignment = wdBaselineAlignAuto End With End Sub每一行代码给个注释
时间: 2024-01-01 22:06:47 浏览: 145
这是一段 VBA 代码,用于设置选定文本的段落格式。下面是每一行代码的注释:
```
Sub 宏12()
' 定义一个名为 "宏12" 的子程序
With Selection.ParagraphFormat
' 选择所选文本的段落格式
.LeftIndent = CentimetersToPoints(0.18)
' 设置左缩进为 0.18 厘米
.RightIndent = CentimetersToPoints(0.18)
' 设置右缩进为 0.18 厘米
.SpaceBefore = 5
' 设置段前间距为 5 磅
.SpaceBeforeAuto = False
' 禁用自动段前间距
.SpaceAfter = 5
' 设置段后间距为 5 磅
.SpaceAfterAuto = False
' 禁用自动段后间距
.LineSpacingRule = wdLineSpaceDouble
' 设置行距规则为双倍行距
.Alignment = wdAlignParagraphJustify
' 设置对齐方式为两端对齐
.WidowControl = True
' 启用孤行控制
.KeepWithNext = False
' 禁用与下一段同页显示
.KeepTogether = False
' 禁用段内不分页
.PageBreakBefore = False
' 禁用段前分页
.NoLineNumber = False
' 启用行号
.Hyphenation = True
' 启用断字
.FirstLineIndent = CentimetersToPoints(0.35)
' 设置首行缩进为 0.35 厘米
.OutlineLevel = wdOutlineLevelBodyText
' 设置大纲级别为正文级别
.CharacterUnitLeftIndent = 1
' 设置字符级左缩进为 1 个字符宽度
.CharacterUnitRightIndent = 1
' 设置字符级右缩进为 1 个字符宽度
.CharacterUnitFirstLineIndent = 2
' 设置首行字符级缩进为 2 个字符宽度
.LineUnitBefore = 1
' 设置段前行距为 1 行
.LineUnitAfter = 1
' 设置段后行距为 1 行
.MirrorIndents = False
' 禁用镜像缩进
.TextboxTightWrap = wdTightNone
' 设置文本框环绕方式为无
.CollapsedByDefault = False
' 禁用默认折叠
.AutoAdjustRightIndent = True
' 启用自动调整右缩进
.DisableLineHeightGrid = False
' 启用行高栅格
.FarEastLineBreakControl = True
' 启用远东文本换行控制
.WordWrap = True
' 启用自动换行
.HangingPunctuation = True
' 启用悬挂标点
.HalfWidthPunctuationOnTopOfLine = False
' 禁用半角标点在行首
.AddSpaceBetweenFarEastAndAlpha = True
' 启用远东文本与字母之间添加空格
.AddSpaceBetweenFarEastAndDigit = True
' 启用远东文本与数字之间添加空格
.BaseLineAlignment = wdBaselineAlignAuto
' 设置基线对齐方式为自动
End With
End Sub
```
阅读全文