Sub HighlightAndColorText()
Dim doc As Document
Dim rng As Range
Set doc = ActiveDocument
Set rng = doc.Content
With rng.Find
.ClearFormatting
.Font.Color = RGB(0, 0, 255) ' Blue font color
.Font.Size = 10 ' Font size
.Font.Name = "Century Gothic" ' Font style
Do While .Execute(Forward:=True, Format:=True) = True
' Set the background color to yellow
rng.Shading.BackgroundPatternColor = wdColorBlack
' Change the font color to white
rng.Font.Color = RGB(255, 255, 255)
' Move the search range to the end of the current found text
rng.Collapse Direction:=wdCollapseEnd
Loop
End With
End SubTuesday, December 24, 2024
VBA Word - Format Text of word document based on the properties of text
The following VBA code finds text with properties such as color, size and name in Word document and change their color etc.
Subscribe to:
Post Comments (Atom)
Hot Topics
-
In the previous post we have learnt about SSMS (SQL Server Management Studio) and how to connect with a SQL Server instance. In this post w...
-
By Ajeet Kumar RADAR CHART In radar chart, the categorical variable is displayed as spikes radiating from a central point. The values o...
-
In previous post , we learnt basic introduction to SQL Server . In this post we will learn about SSMS (SQL Server Management Studio) softwar...
No comments:
Post a Comment