vba在word文档中插入文字并设置相应的文字属性
时间:2023-12-12 23:30:41
下面的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英寸
标签:vba在word文档中插入文字并设置相应的文字属性
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Excel中DEC2BIN函数的语法和用法
2023-11-01 02:12:37
![](https://img.aspxhome.com/file/2023/4/a155824_0s.png)
microsoft office excel加密的方法
2022-10-12 19:39:52
Win10应用商店无法打开怎么办?Win10应用商店无法打开的解决方法
2023-10-13 22:09:07
![](https://img.aspxhome.com/file/2023/0/52300_0s.png)
Excel怎么竖着打字
2023-12-09 00:50:27
![](https://img.aspxhome.com/file/2023/8/a153738_0s.png)
Excel合并单元格的两种简单方法
2022-04-24 08:33:34
![](https://img.aspxhome.com/file/2023/2/38512_0s.gif)
TinyPDF虚拟打印机怎么用 TinyPDF虚拟打印机使用教程
2022-07-13 08:27:44
![](https://img.aspxhome.com/file/2023/4/a306410_0s.jpg)
在cenots下使用iso光盘文件重新安装CentOS的方法步骤
2022-05-14 14:22:32
阿里旺旺登录失败什么原因?电脑阿里旺旺登录不了怎么办?
2023-06-10 18:26:56
![](https://img.aspxhome.com/file/2023/30/a264466_0s.jpeg)
win10系统鼠标很卡怎么办 win10鼠标卡顿的解决办法
2022-06-24 07:43:04
![](https://img.aspxhome.com/file/2023/28/a239108_0s.jpg)
win11桌面图标隔开很宽要怎么解决?三种解决方法分享!
2023-04-04 01:43:34
![](https://img.aspxhome.com/file/2023/30/a265295_0s.jpg)
ROG升级win11系统教程
2022-09-16 07:53:58
![](https://img.aspxhome.com/file/2023/30/a269414_0s.png)
Win7纯净版电脑桌面黑了没背景怎么解决?
2022-01-23 16:18:53
![](https://img.aspxhome.com/file/2023/26/a229035_0s.png)
Win10系统如何设置动态锁?Win10动态锁设置教程
2022-06-18 01:09:13
![](https://img.aspxhome.com/file/2023/26/a219499_0s.jpg)
wps表格怎样画折线图
2023-11-02 07:34:36
夜神模拟器卡90%修复方法
2022-07-24 07:52:22
![](https://img.aspxhome.com/file/2023/30/a269406_0s.jpg)
Excel工作表保护设置
2022-12-09 22:00:40
![](https://img.aspxhome.com/file/2023/1/39211_0s.jpg)
喜马拉雅怎么搜索电台
2023-07-14 19:59:49
![](https://img.aspxhome.com/file/2023/9/a341208_0s.png)
excel2007工作表中如何按位置和按分类合并计算
2023-08-29 13:42:13
![](https://img.aspxhome.com/file/2023/8/a140368_0s.jpg)
Win10系统Edge浏览器小娜助手功能详细介绍
2022-06-30 09:30:20
![](https://img.aspxhome.com/file/2023/1/a277488_0s.jpg)
server2012文件夹、局域网共享设置权限以及server2012r2文件共享权限设置方法
2022-02-12 05:14:32
![](https://img.aspxhome.com/file/2023/28/a242201_0s.jpg)