欢迎来到科站长!

office激活

当前位置: 主页 > 网站运营 > office激活

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

时间:2025-05-10 15:43:38|栏目:office激活|点击:

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


上一篇:#实践笔记#本地配置PHPnow与WordPress运行环境

栏    目:office激活

下一篇:VBA批量替换多个WORD文档中的内容

本文标题:Vba全面修改Word段落属性有效代码

本文地址:https://fushidao.cc/wangzhanyunying/13784.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 科站长 版权所有冀ICP备14023439号