Results 1 to 11 of 11
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Remove hilighting (xpp 2003)

    Hi

    In our documentation we use <font color=red> red italicised </font color=red> text to indentify changes and <span style="background-color: #FFFF00; color: #000000; font-weight: bold">hilighted titles</span hi> to indentify the sections in the TOC that have changes in them.

    My problem is that I would like to automate the removal of these "hilights" before making new amendments. I have tried various ways to get the "remove hilighting" into code but no luck.

    Can anyone help?

    cheers
    cheers

    Phil Carter

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Remove hilighting (xpp 2003)

    Can you use Edit>Replace?

    <code>Sub ClearAllHighlights()
    With Selection.Find ' Settings to find highlight and
    .Text = "" ' replace with no highlight
    .ClearFormatting
    .Format = True
    .Highlight = True
    With .Replacement
    .ClearFormatting
    .Highlight = False
    .Text = "^&"
    End With
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    End With
    With Selection.Find ' Reset to more normal settings
    .Text = ""
    .ClearFormatting
    .Format = False
    .Replacement.ClearFormatting
    End With
    End Sub</code>

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Remove hilighting (xpp 2003)

    I think you will need to use a Search and Replace for the red italicised text but the highlighting is considerably easier...
    <pre>ActiveDocument.Range.HighlightColorIndex = wdNoHighlight</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Remove hilighting (xpp 2003)

    Jefferson

    Thanks once again works just fine. Th problem I have now is I cannot get the find and replace redtext to work from a macro.
    cheers

    Phil Carter

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Remove hilighting (xpp 2003)

    Andrew

    Thanks for that, works great. I cannot get the find and replace redtext to work form a macro.

    Can you help?

    cheers
    cheers

    Phil Carter

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Remove hilighting (xpp 2003)

    Try this:

    With Selection.Find
    .ClearFormatting
    .Format = True
    .Font.Color = wdColorRed
    .Font.Italic = True
    .Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    With .Replacement
    .ClearFormatting
    .Font.Color = wdColorAutomatic
    .Font.Italic = False
    .Text = "^&"
    End With
    .Execute Replace:=wdReplaceAll
    End With

  7. #7
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Remove hilighting (xpp 2003)

    Hans thanks for that.

    Combined with Andrews suggestion for removing the hiliting this works great except I have the date in a footer that is also in red italics and this was not changed. When I did the manual find and replacce ths was changed.

    What needs to be added?

    cheers
    cheers

    Phil Carter

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Remove hilighting (xpp 2003)

    You have to loop through the storyranges of the document:

    Dim rng As Range
    For Each rng In ActiveDocument.StoryRanges
    With rng.Find
    .ClearFormatting
    .Format = True
    .Font.Color = wdColorRed
    .Font.Italic = True
    .Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    With .Replacement
    .ClearFormatting
    .Font.Color = wdColorAutomatic
    .Font.Italic = False
    .Text = "^&"
    End With
    .Execute Replace:=wdReplaceAll
    End With
    Next rng

  9. #9
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Remove hilighting (xpp 2003)

    Hans thanks again

    That worked a treat.

    Now what does this do? .Text = "^&"

    cheers
    cheers

    Phil Carter

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Remove hilighting (xpp 2003)

    ^& is the code for 'the text that has been found'; it can only be used in the 'Replace with' box.

    See Re: Find/Replace Special Characters (Word) for a complete overview.

  11. #11
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Remove hilighting (xpp 2003)

    Thanks Hans
    cheers

    Phil Carter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •