Understanding How to Find Characters That Have Been Painted

Asked 3 months ago, Updated 3 months ago, 12 views

I have a question about Word's VBA fill properties.


Search for grayed-out areas in the number list VBA and get a selection)
I want to unpaint the painted part and put "<""">" before and after that part


I chose Shading.BackgroundPatternColorIndex as my search option, but when I set it up, it doesn't meet the criteria anymore.

If anyone knows how to do it, I would really appreciate it if you could teach me.
Thank you for your cooperation.

Dim Rng As Range
Set Rng = ActiveDocument.Range
    With Selection.Find
    .Font.Shading.BackgroundPatternColorIndex=16
    Do While.Execute
      Selection.Range.Shading.BackgroundPatternColorIndex=0
      Selection.Range.InsertAfterText:=">**"
     Selection.Range.InsertBefore Text:="**<"
    Loop
    End With
End Sub

vba ms-word

2022-09-30 11:22

1 Answers

Shading.BackgroundPatternColorIndex but Highlig when retrieving/setting fluorescent pen colors for normal RangeIt seems to be using htColorIndex.

[Code] You can rewrite the Word Macro article that erases the fluorescent pen of a particular color.
Below is the sample code.
Please note that InsertAfter will be inserted at the beginning of the next line if the entire line is highlighted in the sample code.

SubModifyHighlights()
    ActiveDocument.Range(0,0).Select
    With Selection.Find
        .Highlight=True
        .Forward=True
        .Wrap=wdFindContinue
        Do While.Execute
            If Selection.Range.HighlightColorIndex=16 Then
                Selection.Range.HighlightColorIndex=wdNoHighlight
                Selection.Range.InsertAfterText:=">**" 
                Selection.Range.InsertBefore Text:="**<" 
            End If
            Selection.Collapse Direction: =wdCollapseEnd
        Loop
    End With
End Sub


2022-09-30 11:22

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.