您当前的位置: 首页 > 办公软件教程 > Word教程 浏览
Vba全面修改Word段落属性有效代码
发布时间:2015-10-31    点击率:次    来源:www.sytcke.com    作者:电脑技术学习网

  下面的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;//段中不分页

  WApp.Selection.ParagraphFormat.PageBreakBefore = 0;//段前分页

  WApp.Selection.ParagraphFormat.NoLineNumber = 0;//取消行号

  WApp.Selection.ParagraphFormat.Hyphenation = 1;//取消段字

  WApp.Selection.ParagraphFormat.FirstLineIndent = WApp.CentimetersToPoints(float.Parse("0"));//首行缩进

  WApp.Selection.ParagraphFormat.OutlineLevel = Microsoft.Office.Interop.Word.WdOutlineLevel.wdOutlineLevelBodyText;

  WApp.Selection.ParagraphFormat.CharacterUnitLeftIndent = float.Parse("0");

  WApp.Selection.ParagraphFormat.CharacterUnitRightIndent = float.Parse("0");

  WApp.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = float.Parse("0");

  WApp.Selection.ParagraphFormat.LineUnitBefore = float.Parse("0");

  WApp.Selection.ParagraphFormat.LineUnitAfter = float.Parse("0");

  WApp.Selection.ParagraphFormat.AutoAdjustRightIndent = 1;

  WApp.Selection.ParagraphFormat.DisableLineHeightGrid =0;

  WApp.Selection.ParagraphFormat.FarEastLineBreakControl =1;

  WApp.Selection.ParagraphFormat.WordWrap = 1;

  WApp.Selection.ParagraphFormat.HangingPunctuation = 1;

  WApp.Selection.ParagraphFormat.HalfWidthPunctuationOnTopOfLine = 0;

  WApp.Selection.ParagraphFormat.AddSpaceBetweenFarEastAndAlpha = 1;

  WApp.Selection.ParagraphFormat.AddSpaceBetweenFarEastAndDigit = 1;

  WApp.Selection.ParagraphFormat.BaseLineAlignment = Microsoft.Office.Interop.Word.WdBaselineAlignment.wdBaselineAlignAuto;

来源 电脑技术网 www.sytcke.com
发表留言
发表留言请先登录!
免责声明:本站发布的信息和评论纯属网民个人行为,并不代表本站立场,如发现有违法信息或侵权行为,请直接与本站管理员联系,我们将在收到您的信息后24小时内作出处理!