Find all instances of yellow text and change font color to red

前端 未结 3 1470
野趣味
野趣味 2021-01-03 01:47

I need a vba macro that searches for all text that has font color as yellow within a MS Word 2007 document and changes it to red. The yellow color won\'t show in the printou

3条回答
  •  北海茫月
    2021-01-03 02:18

    There's actually a non-programming solution for this. I've tried it in Word 97, so I'd assume Word 2007 would still allows this:

    1. Open the Search & Replace dialog.
    2. Tick the checkbox that says, Pattern search (or similar).
    3. As search term, enter (?).
    4. Select a formatting for the search (yellow text color).
    5. As replacement term, enter \1.
    6. Select the formatting for the replacement (red text color).
    7. Then search and replace everything.

    Steps 2, 3 and 5 (entering search and replace regular expressions) may not actually be necessary.

    If you definitely need VBA code, you should be able to record the above steps as a macro and then look at the generated code.

提交回复
热议问题