更新时间:2023-12-02 18:03:40
和你一样手动:通过选择范围(单个字符或单词或段落或字符集,单词或段落)并从功能区推送粗体
命令。
看看这里:
如何:以编程方式定义和选择文档中的范围 [ ^ ]
如何:以编程方式格式化文档中的文本 [ ^ ]
Range.Bold [ ^ ] property;)
注意:如果您将文档另存为文本,则会丢失格式。
提示:运行MS Word应用程序。创建新文档时,键入一些文本,然后开始录制宏。选择文字并加粗。停止录音。按ALT + F11切换到CodePane。
这是我得到的:
In the same way as you do it manually: by selecting range (single character or word or paragraph or set of characters, words or paragraphs) and pushingBold
command from ribbon.
Have a look here:
How to: Programmatically Define and Select Ranges in Documents[^]
How to: Programmatically Format Text in Documents[^]
Range.Bold[^] property ;)
Note: if you save a document as a text, you'll lose formatting.
Tip: Run MS Word application. When new document is created, type some text, then start recording macro. Select text and bold it. Stop recording. Push ALT+F11 to switch to CodePane.
Here is what i get:
Sub Macro1()
'
' Macro1 Macro
'
'
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=7, Extend:=wdExtend
Selection.Font.Bold = wdToggle
End Sub