您当前的位置: 首页 > 办公软件教程 > Word教程 浏览
vba在word文档中插入文字并设置相应的文字属性
发布时间:2015-10-31    点击率:次    来源:www.sytcke.com    作者:电脑技术学习网

  下面的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英寸

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