VBA Word 格式化 Selection.typetext
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13400869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 14:25:39 来源:igfitidea点击:
VBA Word formatting Selection.typetext
提问by ShadyBaker
I am still a beginner with this. Can you tell my why this is not formatting the selection?
我仍然是这个的初学者。你能告诉我为什么这不是格式化选择吗?
Selection.TypeText "title"
With Selection
.Font.Bold = True
.Font.Name = "Arial"
.Font.ColorIndex = wdDarkBlue
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.ParagraphFormat.SpaceAfter = 0
End With
回答by Olle Sj?gren
It does format the text, but only text added afterthe With Selection
command.
它确实格式化文本,但仅在命令后添加文本With Selection
。
Change the order, put Selection.TypeText "title"
last, and it will work. :)
更改顺序,放在Selection.TypeText "title"
最后,它会起作用。:)