• Search/replace text shading (Word 2000 SR 1)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Search/replace text shading (Word 2000 SR 1)

    Author
    Topic
    #425933

    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

    Viewing 0 reply threads
    Author
    Replies
    • #982779

      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.

      • #983966

        Thanks Hans. But I’m afraid I still can’t get it to work.
        This works:

            With Selection.Find
                 .ClearFormatting
                 .Format = True
                 .Text = "a"
                 .Execute
            End With
        

        But this doesn’t:

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

        What I really want to do is something like this: In the document ABC appears with a background format, that I want to strip.

            With Selection.Find
                .ClearFormatting
                .Replacement.ClearFormatting
                
                .Format = True
        
                .Text = "ABC"
                .Replacement.Text = "XYZ"
        
                .Replacement.Font.Shading.BackgroundPatternColor = wdColorAutomatic
                
                .Execute Replace:=wdReplaceAll
            End With
        
        • #983973

          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.)

    Viewing 0 reply threads
    Reply To: Search/replace text shading (Word 2000 SR 1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: