按住 Alt + F11,立即開啟 Microsoft Visual Basic for Applications 視窗!
按一下插入 > 模組,然後將下列程式碼複製並貼上至空白模組中:
Sub BoldAll()
Dim xStr As String
xStr = InputBox("Please enter the word that you want to bold:", "Kutools for Word")
If Trim(xStr) = "" Then
MsgBox "Can't be empty!", vbInformation, "Kutools for Word"
Exit Sub
End If
With ActiveDocument.Content.Find
.ClearFormatting
.Text = xStr
.Replacement.ClearFormatting
.Replacement.Font.Bold = True
.Replacement.Text = "^&"
.Wrap = wdFindStop
.Format = True
.Forward = True
.Execute Replace:=wdReplaceAll
End With
End Sub
在插入程式碼後,按下 F5 執行,系統將立即顯示一個對話方塊,請輸入您要加粗的文字。
按一下「確定」,文件中所有指定文字的實例將立即套用粗體格式。
使用 Kutools for Word 在 Word 文件中將多個文字的所有實例加粗
除了使用 VBA 之外,Kutools for Word 還透過其「批次取代」功能,提供更簡便的方式,讓您一次將多個指定文字加粗。當您希望無需撰寫任何程式碼,就能同時對多個特定文字套用粗體格式時,這是最理想的方法。
Kutools for Word
Kutools for Word 讓您透過 Microsoft Word 內建的實用工具,輕鬆快速完成日常文件任務——無需編寫程式碼,也無需繁瑣設定。