reset font format to default but keep the bold formatting..>>

M

michiel

hello, I'm looking for a way to remove all font formatting from a Word
document except the bold. Appreciate any suggestions. Thanks, Michiel
 
J

Jezebel

1. Define a character style called maybe "BoldText". The actual style
features are irrelevant -- it's only the name you need. Not that it must be
a *character* style, not a paragraph style.

2. Use Find and Replace. Leave the Find box blank and set the format to Font
Bold. Leave the Replace box blank and set the format to Style =
"BoldText". Click Replace All.

3. Select the entire document and reset the styles: Ctrl-A Ctrl-Q
Ctrl-Space.

4. Use the above Find and Replace in reverse: Find format > Style =
"BoldText", Replace with format > Font > bold.

5. Delete the "BoldText" style.
 
M

michiel

thanks, but that doesn't really work. Problem is that by clearing the format
thru ctrl+q and ctrl+space, you also delete the boldtext style so that the
second find and replace doesn't work anymore. But thanks for taking the time
to respond to my question!
 
K

Klaus Linke

Hi Michiel,

Two snags:
-- Bold may be applied by styles.
-- If you have a bold style and something in that has been unbolded, you
likely don't want to loose that either?

You could
-- tag bold text first (Find/Replace "Font = bold" with <b>^&</b>),
(both bold from styles and manual bolding will be tagged)
-- reset the font,
-- remove all bold formatting (say by replacing "bold" with "not bold"),
-- then replace (using "Match wildcards"):
Find what: \<b\>(*)\</b\>
Replace with: \1 ((+ Format > Font = bold))

-- Finally save the doc before you work further on it. You'll have applied
manual bold formatting to all bold styles (headings?...).
A Save will enable Word to clean that unnecessary formatting up.

Greetings,
Klaus
 
H

Helmut Weber

Hi Klaus,

how about this one,
coded with respect to speed
and with respect to avoiding repagination by inserting tags,
at least to some extend.

I think in principle it could be used in quite a variety of cases:

Sub test000()
Dim oPrg As Paragraph
Dim rWrd As Range
Dim rChr As Range
For Each oPrg In ActiveDocument.Paragraphs
If oPrg.Range.Font.Bold = False Then
oPrg.Range.Font.Reset
ElseIf oPrg.Range.Font.Bold = True Then
oPrg.Range.Font.Reset
oPrg.Range.Font.Bold = True
ElseIf oPrg.Range.Font.Bold = 9999999 Then
For Each rWrd In oPrg.Range.Words
If rWrd.Font.Bold = False Then
rWrd.Font.Reset
ElseIf rWrd.Font.Bold = True Then
rWrd.Font.Reset
rWrd.Font.Bold = True
ElseIf rWrd.Font.Bold = 9999999 Then
For Each rChr In rWrd.Characters
If rChr.Font.Bold = True Then
rChr.Font.Reset
rChr.Font.Bold = True
ElseIf rChr.Font.Bold = False Then
rChr.Font.Reset
End If
Next
End If
Next
End If
Next
End Sub


I am not sure, whether formatting something as bold,
which is bold anyway, may cause problems sometime.

--
Gruß aus Landsberg am Lech

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
K

Klaus Linke

Hi Helmut,

Interesting approach, looks well optimized! Though 3 replacements and
"FontReset" on the whole doc is likely pretty fast, too...
Not sure what program would "win".

It might depend on the specifics of the document (how large? how much bold
text? ...).

Regards,
Klaus
 
M

michiel

Klaus Linke said:
Hi Michiel,

Two snags:
-- Bold may be applied by styles.
-- If you have a bold style and something in that has been unbolded, you
likely don't want to loose that either?

You could
-- tag bold text first (Find/Replace "Font = bold" with <b>^&</b>),
(both bold from styles and manual bolding will be tagged)
-- reset the font,
-- remove all bold formatting (say by replacing "bold" with "not bold"),
-- then replace (using "Match wildcards"):
Find what: \<b\>(*)\</b\>
Replace with: \1 ((+ Format > Font = bold))

-- Finally save the doc before you work further on it. You'll have applied
manual bold formatting to all bold styles (headings?...).
A Save will enable Word to clean that unnecessary formatting up.

Greetings,
Klaus
 
M

michiel

Helmut Weber said:
Hi Klaus,

how about this one,
coded with respect to speed
and with respect to avoiding repagination by inserting tags,
at least to some extend.

I think in principle it could be used in quite a variety of cases:

Sub test000()
Dim oPrg As Paragraph
Dim rWrd As Range
Dim rChr As Range
For Each oPrg In ActiveDocument.Paragraphs
If oPrg.Range.Font.Bold = False Then
oPrg.Range.Font.Reset
ElseIf oPrg.Range.Font.Bold = True Then
oPrg.Range.Font.Reset
oPrg.Range.Font.Bold = True
ElseIf oPrg.Range.Font.Bold = 9999999 Then
For Each rWrd In oPrg.Range.Words
If rWrd.Font.Bold = False Then
rWrd.Font.Reset
ElseIf rWrd.Font.Bold = True Then
rWrd.Font.Reset
rWrd.Font.Bold = True
ElseIf rWrd.Font.Bold = 9999999 Then
For Each rChr In rWrd.Characters
If rChr.Font.Bold = True Then
rChr.Font.Reset
rChr.Font.Bold = True
ElseIf rChr.Font.Bold = False Then
rChr.Font.Reset
End If
Next
End If
Next
End If
Next
End Sub


I am not sure, whether formatting something as bold,
which is bold anyway, may cause problems sometime.

--
Gruß aus Landsberg am Lech

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top