1

Topic: Text search in contents of a bookmark of the text

Hello, the code to find the text in bookmark contents in the Word - finds all coincidence and if to find and replace with something that probably a text amount the size of a bookmark in which increases also we search is not enumerated, at the same time endPos increases, at the guru look please, what I do not so? Thanks

Sub Handling ()
Dim endPos As Long
Dim R As Range
With ActiveDocument. Bookmarks (ActiveDocument. Range. Bookmarks (1).Name)
If.Range Like "*checkboxpunkt *" Then
Set R =.Range
endPos =.End
With R.Find
.MatchWildcards = True
.Text = "[\<] checkboxpunkt> *"
.Forward = True
Do While.Execute = True And R.End <= endPos
Debug. Print R.End
' R.Select
R.Text = "<span class ="" punkt "" data-st=data-ch=data-pt =) <span class = "" punkt "" data-st=data-ch=data-pt =) <span class = "" punkt "" data-st=data-ch=data-pt =) <span class = "" punkt "" data-st=data-ch=data-pt =) <span class = "" punkt "" data-st=data-ch=data-pt =) <span class = "" punkt "" data-st=data-ch=data-pt =)"
R.Collapse wdCollapseEnd
Loop
End With
End If
End With
MsgBox "11"
'
End Sub

2

Re: Text search in contents of a bookmark of the text

The output found, after a line Loop to specify and send on the subsequent circles to fulfill search, but in mine it as that is not correct?

If ActiveDocument. Bookmarks (ActiveDocument. Range. Bookmarks (1).Name).Range Like "*checkboxpunkt *" Then GoTo Back