下面的WAPP是事先定义的word文档工程变量。
以下代码为通过VBA代码修改Word段落的缩进、段落间距、行距、分页等。
//段落格式设定
WApp.Selection.ParagraphFormat.LeftIndent = WApp.CentimetersToPoints(float.Parse("0"));//左缩进
WApp.Selection.ParagraphFormat.RightIndent = WApp.CentimetersToPoints(float.Parse("0"));//右缩进
WApp.Selection.ParagraphFormat.SpaceBefore =float.Parse("0");//段前间距
WApp.Selection.ParagraphFormat.SpaceBeforeAuto =0;//
WApp.Selection.ParagraphFormat.SpaceAfter = float.Parse("0");//段后间距
WApp.Selection.ParagraphFormat.SpaceAfterAuto = 0;//
WApp.Selection.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceSingle;//单倍行距
WApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;//段落2端对齐
WApp.Selection.ParagraphFormat.WidowControl = 0;//孤行控制
WApp.Selection.ParagraphFormat.KeepWithNext = 0;//与下段同页
WApp.Selection.ParagraphFormat.KeepTogether = 0;//段中不分页<