StyleSheets Collection

StyleSheets Collection
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Document
Aa168164.parchild(en-us,office.10).gifStyleSheets
Aa168164.space(en-us,office.10).gifAa168164.parchild(en-us,office.10).gifStyleSheet

A collection of StyleSheet objects that represents the cascading style sheets attached to a document.  The StyleSheets collection includes all cascading style sheets displayed in the Linked CSS Style Sheets dialog box, accessed using the Templates and Add-ins command (Tools menu).

Using the StyleSheets collection

Use the StyleSheets property to return the StyleSheets collection. Use the Add method to add a style sheet to the StyleSheets collection. The following example adds three cascading style sheets to the active document and sets the third as the highest in precedence.

  Sub AddCSS()
    With ActiveDocument.StyleSheets
        .Add FileName:="Web.css", Title:="Web Styles"
        .Add FileName:="New.css", Linktype:=wdStyleSheetLinkTypeImported, _
            Title:="New Styles"
        .Add FileName:="Defs.css", Title:="Definitions", _
            Precedence:=wdStyleSheetPrecedenceHighest
    End With
End Sub