SpanElement を DOM の現在の (カーソル) 位置に挿入したかったのです。私はこのVB6関数を使用します:
Private Function InsertSpan(Tipo As String, Nome As String)
Dim oSpan As MSHTML.HTMLSpanElement
Dim oCurElement As MSHTML.IHTMLElement
Dim oDOM As MSHTML.HTMLDocument
Set oDOM = HTMLEdit.DOM
Set oCurElement = oDOM.activeElement
Set oSpan = oDOM.createElement("SPAN")
oSpan.Id = Tipo & "." & Nome
oSpan.className = Tipo
oSpan.innerHTML = "<b><font size='3' color='#000000'></font></b>"
oSpan.lastChild.lastChild.innerText = "[" & Nome & "]"
oSpan.Style.backgroundColor = "yellow"
oSpan.hideFocus = True
oSpan.contentEditable = "false"
oSpan.Style.verticalAlign = "middle"
oCurElement.appendChild oSpan
oDOM.parentWindow.Focus
End Function
ただし、SpanElement は現在の要素に追加されます。ありがとう、ルイージ。