object to an IHTMLTxtRange
object.
expression.applyToRange(range)
expression Required. An expression that returns one of the objects in the Applies To list.
range Required IHTMLTxtRange object. The text range to which to apply the style.
Example
The following example creates an IFPStyleState object and applies its style properties to a text range stored in the objRng variable.
Sub ApplyStyleToRange()
Dim objSS As IFPStyleState
Dim objDoc As FPHTMLDocument
Dim objRng As IHTMLTxtRange
Set objDoc = Application.ActiveDocument
objDoc.body.innerHTML = "<h1><b>Heading 1</b></h1>"
Set objSS = objDoc.createStyleState
Set objRng = objDoc.body.createTextRange
With objSS
.gather objRng
.fontFamily = "Arial"
.Color = vbRed
.textAlign = "right"
.setProperty "background-color", vbBlue
.textDecorationLineThrough = True
.textDecorationOverline = True
.textDecorationUnderline = True
.textTransform = "uppercase"
.applyToRange objRng
End With
Set objSS = Nothing
Set objDoc = Nothing
Set objRng = Nothing
End Sub