View Single Post
 
Old 01-17-2024, 04:31 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Hi! Try this:
Code:
Sub Find_Str_Add_Shape()
'In the selection, find the inputboxed string & add a transparent
'blue oval shape over it.
    
Dim rng As range
Dim stri As String
Dim shp As shape
    
    Set rng = selection.range
    stri = InputBox("Enter the string to find:")
    rng.Find.text = stri
    rng.Find.Execute
    
    If rng.Find.found Then
        rng.Select
        Set shp = ActiveDocument.Shapes.AddShape(msoShapeOval, _
        selection.Information(wdHorizontalPositionRelativeToPage), _
        selection.Information(wdVerticalPositionRelativeToPage), _
        20, 16)
        With shp
            .Fill.Transparency = 1 'Full transparency
            .Line.ForeColor.RGB = RGB(0, 0, 255) 'Blue color
            .Line.Visible = msoTrue
        End With
    End If
End Sub
You may change 'Set rng = selection.range' to 'Set rng = ActiveDocument.range'.
Reply With Quote