Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Search/replace text shading (Word 2000 SR 1)

    This seems like a silly question, that I should know how to solve. But it's just not working for me today.
    How can I search (and/or Replace) for text that has been given a background shading (with select some character, then Format, Borders and Shading, Shading tab, pick a colour and choose 'Apply to:' text).
    Thanks
    Peter

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

    Re: Search/replace text shading (Word 2000 SR 1)

    I think you'll need code for this. For example:

    With Selection.Find
    .ClearFormatting
    .Format = True
    .Font.Shading.BackgroundPatternColor = wdColorYellow
    .Execute
    End With

    to find text with yellow shading.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Search/replace text shading (Word 2000 SR 1)

    Thanks Hans. But I'm afraid I still can't get it to work.
    This works:
    <pre> With Selection.Find
    .ClearFormatting
    .Format = True
    .Text = "a"
    .Execute
    End With
    </pre>


    But this doesn't:
    <pre> With Selection.Find
    .ClearFormatting
    .Format = True
    .Font.Shading.BackgroundPatternColor = wdColorLightGreen
    .Execute
    End With
    </pre>


    What I really want to do is something like this: In the document ABC appears with a background format, that I want to strip.
    <pre> With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting

    .Format = True

    .Text = "ABC"
    .Replacement.Text = "XYZ"

    .Replacement.Font.Shading.BackgroundPatternColor = wdColorAutomatic

    .Execute Replace:=wdReplaceAll
    End With
    </pre>


  4. #4
    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: Search/replace text shading (Word 2000 SR 1)

    You want to replace ABC with XYZ? The following doesn't do that, but it will reset the shading color of the found text:

    With Selection.Find
    .ClearFormatting
    .Format = True
    .Font.Shading.BackgroundPatternColor = wdColorYellow
    While .Execute = True
    .Parent.Font.Shading.BackgroundPatternColor = wdColorAutomatic
    Wend

    .Format = False
    .ClearFormatting
    End With

    (The .Parent of the Selection.Find object is the Selection object.)

Posting Permissions

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