clone Method

Microsoft FrontPage Visual Basic

object.

expression.Clone

expression    Required. An expression that returns an IFPStyleState object.

Example

The following example inserts HTML into the specified document and creates two IHTMLElement objects, one for each paragraph element inserted. Then it creates an IFPStyleState object called objSS1 and adds font formatting properties. It then uses the Clone method to create a copy of the IFPStyleState object that is stored in the objSS2 variable, and modifies the background color of the IFPStyleState object called objSS2. Once the IFPStyleState objects are created, they are applied to the element object variables objElement1 and objElement2.

Sub CloneStyleState()
    Dim objDoc As FPHTMLDocument
    Dim objSS1 As IFPStyleState
    Dim objSS2 As IFPStyleState
    Dim objElement1 As IHTMLElement
    Dim objElement2 As IHTMLElement
    
    Set objDoc = Application.ActiveDocument
    
    objDoc.body.innerHTML = "<p>Line One</p>" & vbCrLf & _
        "<p>Line Two</p>"
    
    Set objElement1 = objDoc.all.tags("p").Item(0)
    Set objElement2 = objDoc.all.tags("p").Item(1)
    
    Set objSS1 = objDoc.createStyleState
    objSS1.fontStyle = "italic"
    
    Set objSS2 = objSS1.Clone
    objSS2.backgroundColor = vbBlue
    
    objSS1.applyToElement objElement1
    objSS2.applyToElement objElement2
    
    Set objElement2 = Nothing
    Set objElement1 = Nothing
    Set objSS2 = Nothing
    Set objSS1 = Nothing
    Set objDoc = Nothing
End Sub