Dzwebs.Net

撰写电脑技术杂文十余年

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

Admin | 2013-2-16 10:53:11 | 被阅次数 | 7138

温馨提示!

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

  下面的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杂文

上一篇:取消WORD按回车键就生成自动序号

下一篇:打开word文档提示“Word 无法启动转换器 mswrd632

网站备案号:

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

版权属性:

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

联系方式:

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