网页中高亮关键字如何让它不高亮?
网页中高亮关键字如何让它不高亮?
Public Sub HightLight2(nKey$, nDoc As MSHTML.HTMLDocument, Optional ByVal IsLight As Boolean = True, Optional beforeTag$ = vbNullString, Optional afterTag$ = vbNullString)
On Error GoTo due
Dim tBody As MSHTML.HTMLBody
Dim oRange As MSHTML.IHTMLTxtRange
If LenB(beforeTag) = 0 Then
beforeTag = "<span style='background-color:yellow'>"
End If
If LenB(afterTag) = 0 Then
afterTag = "</span>"
End If
Set tBody = nDoc.body
If Not tBody Is Nothing Then
Set oRange = tBody.createTextRange
If Not oRange Is Nothing Then
oRange.collapse
oRange.Select
Debug.Print "cretee range"
'height light the keyword ,jerry
If IsLight Then
While oRange.findText(nKey)
Call oRange.pasteHTML(beforeTag & oRange.Text & afterTag)
Call oRange.moveStart("character", 1)
Wend
Else
While oRange.findText(nKey)
Call oRange.pasteHTML(nKey)
Call oRange.moveStart("character", 1)
Wend
End If
End If
End If
Exit Sub
due:
Debug.Print "hl2 err:"; Err.Description, Err.Number
Resume Next
End Sub
这是高亮关键字的代码
如何让它不高亮?