Dzwebs.Net

撰写电脑技术杂文十余年

Vba全面修改Word段落属性有效代码

Admin | 2011-11-2 1:55:30 | 被阅次数 | 9430

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  下面的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;


该杂文来自: Word杂文

上一篇:Word Vba修改页边距、纸张纵向、装定线等的代码

下一篇:word制表位和TAB、空格

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计