createStyleSheet 方法

       

创建或修改给定级联样式表。

expression.createStyleSheet(bstrHref, lIndex)

expression  必选。返回“应用于”列表中的对象之一的表达式。

bstrHref  可选。String 类型。代表级联样式表的路径。

lIndex  可选。Long 类型。指定样式表在样式表集合中的位置。

说明

createStyleSheet 方法包含可更改该方法的行为的可选参数。通过将 bstrHref 参数指定为样式表文件的路径,此方法可用于创建指向现有样式表的链接。通过使用活动文档的 Style 属性访问 Style 对象,createStyleSheet 方法可用于修改现有样式表。最后,如果不指定参数,此方法可用于创建返回 FPHTMLStyleSheet 对象的新样式表。

示例

下列示例创建从当前文档到现有级联样式表的链接。在此例中,bstrHref 参数指定了级联样式表的文件路径。

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

下列示例创建新的样式表,并且将其返回到名为“objSS”的变量。没有指定参数。

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