IFPStyleState Object

Microsoft FrontPage Visual Basic

IFPStyleState Object

Multiple objects IFPStyleState
IFPStyleLength

Contains information about the styles associated with a given element or text range on the current page. The IFPStyleState object allows you to view and edit any style property associated with a given element. Once style properties are modified, Microsoft FrontPage uses the new style information to render the new text based on the original styles.

Using the IFPStyleState object

Use the CreateStyleState property of the FPHTMLDocument object to create an IFPStyleState object. The following example creates a new IFPStyleState object and stores it in a variable called objSs.

    Sub NewStyleState()
'Creates a new style state object

    Dim objSs As IFPStyleState
        
    Set objSs = Application.ActiveDocument.createStyleState
End Sub
  

Use the gather method to associate a style state with a specified element or range. The following example creates an IFPStyleState object, associates it with a text range on the active document, and modifies its properties. The resulting text is rendered with the new styles.

    Sub ChangeStyleState()
'Changes the style state of a given text range

    Dim objSs As IFPStyleState
    Dim objRng As IHTMLTxtRange
    
    Application.ActiveDocument.body.innerHTML = "Hello Style State World"
    Set objRng = Application.ActiveDocument.body.createTextRange
    Set objSs = Application.ActiveDocument.createStyleState
    
    objSs.gather objRng
    objSs.fontWeight = 700
    objSs.fontFamily = "arial"
    objSs.Apply
    
End Sub
  

Use the Apply method to apply any changes made to the text range or element.