createStyleSheet Method

       

Creates or modifies a given cascading style sheet.

expression.createStyleSheet(bstrHref, lIndex)

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

bstrHref  Optional. A String that represents the path of the cascading style sheet.

lIndex  Optional. A Long that specifies the position of the style sheet within the style sheets collection.

Remarks

The createStyleSheet method has optional arguments that change the behavior of the method. The method can be used to create a link to an existing style sheet by specifying a style sheet file path for the bstrHref argument. The createStyleSheet method can be used to modify the existing style sheet by using the active document's style property to access the Style object. Finally, by specifying no arguments, the method can be used to create a new style sheet returning an FPHTMLStyleSheet object.

Example

The following example creates a link from the current document to an existing cascading style sheet. In this scenario, the bstrHref argument specifies the file path of the cascading style sheet.

Sub AddStyleSheet()
'Adds a new style sheet to the document

    Dim objApp As FrontPage.Application
    Dim objDoc As DispFPHTMLDocument

    Set objApp = FrontPage.Application
    Set objDoc = objApp.ActiveDocument
    'Create a link to the style sheet
    objDoc.createStyleSheet _
        BstrHref:="C:\Program Files\Microsoft Office\ Office10\1033\PubFtScm\Scheme01.css", _
        lIndex:=1

End Sub

The following example creates a new style sheet and returns it into a variable called "objSS". No arguments are specified.

Sub CreateStyleSheet()
'Creates a new style sheet

    Dim objApp As FrontPage.Application
    Dim objDoc As DispFPHTMLDocument
    Dim objSS as IHTMLStyleSheet

    Set objApp = FrontPage.Application
    Set objDoc = objApp.ActiveDocument
    'Create a style sheet by modifying the current document settings.
    Set objSS = objDoc.CreateStyleSheet

End Sub