欢迎来到科站长!

office激活

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

vba在word文档中插入文字并设置相应的文字属性

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

下面的VBA代码功能,第一步,word当前文档的上面添加文字dzwebs文字。然后,又设置第一段居中对齐,并在该段落之后添加半英寸的间距。将dzwebs的格式设为36磅,隶书字体。

Dim rngFormat As Range

Set rngFormat = ActiveDocument.Range(Start:=0, End:=0)

With rngFormat

.InsertAfter Text:="dzwebs"

.InsertParagraphAfter

With .Font

.Name = "隶书"

.Size = 36

.Bold = True

End With

End With

With ActiveDocument.Paragraphs(1)

.Alignment = wdAlignParagraphCenter

.SpaceAfter = InchesToPoints(0.5)

End With

部分代码解释:

Dim rngFormat As Range定义变量

Set rngFormat = ActiveDocument.Range(Start:=0, End:=0)设置rngFormat变量的位置,位于文档的最上面

With rngFormat

里面的代码功能是设置字体字号等属性

End With

With ActiveDocument.Paragraphs(1)

.Alignment = wdAlignParagraphCenter

.SpaceAfter = InchesToPoints(0.5)

End With

该代码代码功能是添加段后距离为0.5英寸


上一篇:Word删除空行图文教程

栏    目:office激活

下一篇:增加word标题样式中的标题4.标题5.标题6

本文标题:vba在word文档中插入文字并设置相应的文字属性

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

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

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

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

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

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