createStyleState Method

Microsoft FrontPage Visual Basic

createStyleState Method

Returns an IFPStyleState object that represents the style properties associated with a specified text range.

expression.createStyleState

expression    Required. An expression that returns one of the objects in the Applies to list.

Remarks

Use the gather method to prepare an IFPStyleState object to use. Once you've applied the style attributes for the IFPStyleState object, use the Apply method to make the specified changes in the document.

Example

The following example specifies the font name and weight for text in the active document.

Note  This example creates a FONT element with the face attribute specified and a B element around all text in the active document. Note that each section of text is treated separately. For example, opening and closing FONT and B tags are placed around the text in each paragraph in a document and around the text in each table cell. Therefore, if you have the paragraph <p>text</p> it will become <p><font face="Verdana"><b>text</b></font></p>. Also, if a paragraph contains no text, which includes paragraphs that contain nonprinting symbols such as &nbsp; but no other printable symbols, no elements are applied.

    Dim objStyleState As IFPStyleState
Dim objRange As IHTMLTxtRange

Set objRange = Application.ActiveDocument.body.createTextRange
Set objStyleState = Application.ActiveDocument.createStyleState
    
With objStyleState
    .gather objRange
    .fontWeight = 700
    .fontFamily = "Verdana"
    .Apply
End With