I use a web browser control as a html editor in a MS Access 2010 database. I am trying to create a find text function to find certain strings and then select them.
I am using this code which works fine:
Private WithEvents oWeb As WebBrowser
Public Function FindAndHighlight(strText As String)
Dim tr As IHTMLTxtRange
Set oWeb = Me.webbrowser0.Object
Set tr = oWeb.document.body.createTextRange
tr.findText strText
tr.Select
tr.scrollIntoView
End Function
But this only finds the first occurrence of the search string. How do I - after I found the first occurrence - find the next one and then the next and so forth...?
Hope someone can put me on the right track...
BR, Emphyrio
Eventually I found the answer myself. The solution was quite simple actually, looking in retrospect. Once I realized that the selection of the found keyword was also a text range, things fell into place. Here is my solution: