WordVBA---段落格式的设置方法示例

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1/5WordVBA---“段落”格式的设置方法示例一、设置段落的对齐方式段落的“对齐方式”指令格式如下:Selection.ParagraphFormat.Alignment=设置值对齐方式ParagraphFormat.Alignment属性值左对齐wdAlignParagraphLeft居中wdAlignParagraphCenter右对齐wdAlignParagraphRight两端对齐wdAlignParagraphJustify分散对齐wdAlignParagraphDistribute下面示例设置段落的对齐方式为“左对齐”。SubSetAlignment()WithSelection.ParagraphFormat.Alignment=wdAlignParagraphLeftEndWithEndSub“大纲级别”指令格式如下:Selection.ParagraphFormat.OutlineLevel=设置值下面示例设置段落的大纲级别为“正文文本”。SubSetOutlineLevel()WithSelection.ParagraphFormat.OutlineLevel=wdOutlineLevelBodyTextEndWithEndSub2/5在大纲级别的下拉菜单中除“正文文本”外,还有1级到9级的大纲级别,对应的OutlineLevel属性值分别为wdOutlineLevel1、wdOutlineLevel2、……、wdOutlineLevel9。二、设置段落的缩进设置段落的缩进有两种单位:厘米和字符。下面示例将段落的左缩进、右缩进分别设为0.8cm、0.5cmSubSetIndent()WithSelection.ParagraphFormat.LeftIndent=CentimetersToPoints(0.8).RightIndent=CentimetersToPoints(0.5)EndWithEndSub下面示例将段落的左缩进、右缩进分别设为2字符、0字符:SubSetIndent()WithSelection.ParagraphFormat.CharacterUnitLeftIndent=2.CharacterUnitRightIndent=0EndWithEndSub缩进的“特殊格式”1没有“特殊格式”SubSetFirstLineIndent()WithSelection.ParagraphFormat.FirstLineIndent=CentimetersToPoints(0).CharacterUnitFirstLineIndent=0EndWithEndSub3/52“首行缩进”下面指令设置“首行缩进”0.5厘米SubSetFirstLineIndent()WithSelection.ParagraphFormat.FirstLineIndent=CentimetersToPoints(0.5)EndWithEndSub下面指令设置“首行缩进”2字符SubSetFirstLineIndent()WithSelection.ParagraphFormat.CharacterUnitFirstLineIndent=2EndWithEndSub3“悬挂缩进”下面指令设置“悬挂缩进”0.5厘米SubSetFirstLineIndent()WithSelection.ParagraphFormat.FirstLineIndent=CentimetersToPoints(-0.5)EndWithEndSub下面指令设置“悬挂缩进”2字符SubSetFirstLineIndent()WithSelection.ParagraphFormat.CharacterUnitFirstLineIndent=-2EndWithEndSub4/5三、设置段落的“间距”下列指令设置段前间距和段后间距为“自动”Sub.ParagraphSpace()WithSelection.ParagraphFormat.SpaceBeforeAuto=True.SpaceAfterAuto=TrueEndWithEndSub下列指令设置”段前间距”和”段后间距”为“0行”Sub.ParagraphSpace()WithSelection.ParagraphFormat.SpaceBefore=0.SpaceBeforeAuto=False.SpaceAfter=0.SpaceAfterAuto=FalseEndWithEndSub四、设置“行间距”行间距设置值Selection.ParagraphFormat.LineSpacingRule属性值单倍行距wdLineSpaceSingle1.5倍行距wdLineSpace1pt52倍行距wdLineSpaceDouble最小值wdLineSpaceAtLeast下面指令指定最小行距值为16磅:.Selection.ParagraphFormatLineSpacing=16固定值wdLineSpaceExactly下面指令指定固定行距值为20磅:Selection.ParagraphFormat.LineSpacing=20多倍行距wdLineSpaceMultiple下面指令指定行距值为3倍行距5/5.Selection.ParagraphFormatLineSpacing=LinesToPoints(3)下面示例将行间距设为20磅固定值。SubSetLineSpace()WithSelection.ParagraphFormat.LineSpacingRule=wdLineSpaceExactly.LineSpacing=20EndWithEndSub

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功