Re: Apply a user-defined character style to all ocurrences of manual bold formatting but skipping some specific paragraphs

Tech-Archive recommends: Speed Up your PC by fixing your registry



On 28 Jul., 17:09, Helmut Weber <red....@xxxxxxxxxxx> wrote:
Hi Andreas,

what about the idea, that the command
range.font.reset
reveals, whether there was formatting manually applied?

Something along these lines, maybe:

Sub Macro7()
Dim rDcm As Range
Set rDcm = ActiveDocument.StoryRanges(wdMainTextStory)
With rDcm.Find
   .Font.Bold = True
   While .Execute
      rDcm.Font.Reset
      ' rDcm.Select ' for testing
      If rDcm.Font.Bold = False Then
         rDcm.Style = "BoldStyle"
      End If
      ' rDcm.Select ' for testing
   rDcm.start = rDcm.End
   rDcm.End = ActiveDocument.StoryRanges(wdMainTextStory).End
   Wend
End With
End Sub

If you create a new range, by
Set rDcm = ActiveDocument.StoryRanges(wdMainTextStory)
it is not necessary to care about find.options like
   .ClearFormatting
   .Replacement.ClearFormatting
   .Forward = True
   .Wrap = wdFindContinue
etc.

All options are set to their default values.
However, I don't know, what they are. ;-)

Also
activedocument.range seems to be equivalent to
ActiveDocument.StoryRanges(wdMainTextStory).

But I'm not sure about that either.

Whithout covering all possible complications, of course,

cheers

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Hey Helmut,

thanks for the quick answer. I ran it for about 15 min on a document
with 50 pages. I interrupted it since I thought that it had fallen
into an endless loop. I will do some longer testing and let you then.
Regards, Andreas
.



Relevant Pages