Discussion:
Delete all Bold Text in a Macro
(too old to reply)
Greg
2006-08-15 22:12:01 UTC
Permalink
I can't figure out how to record a macro that deletes all Bold Text.

Here is what it recorded for me:

Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

For some reason it doesn't record the fact that the format is all bold.

Can anyone help me?
Helmut Weber
2006-08-15 23:10:37 UTC
Permalink
Hi,
Post by Greg
For some reason it doesn't record
the fact that the format is all bold.
Blame MS. It simply doesn't.

Try this:

Sub Macro10()
With ActiveDocument.Range.Find
.Font.Bold = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End Sub
--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Greg Maxey
2006-08-15 23:14:43 UTC
Permalink
If you want to delete all bold text then use:

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Font.Bold = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End Sub

If you want to remove the Bold formatting and leave the text you could use:
Sub ScratchmacroII()
ActiveDocument.Range.Font.Bold = False
End Sub
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Post by Greg
I can't figure out how to record a macro that deletes all Bold Text.
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
For some reason it doesn't record the fact that the format is all bold.
Can anyone help me?
Continue reading on narkive:
Loading...