Share via


StyleSheets.Add Method

Word Developer Reference

Returns a StyleSheet object that represents a new style sheet added to a Web document.

Syntax

expression.Add(FileName, LinkType, Title, Precedence)

expression   Required. A variable that represents a StyleSheets collection.

Parameters

Name Required/Optional Data Type Description
FileName Required String The path and file name of the cascading style sheet.
LinkType Required WdStyleSheetLinkType Indicates whether the style sheet should be added as a link or imported into the Web document.
Title Required String The name of the style sheet.
Precedence Required WdStyleSheetPrecedence Indicates the level of importance compared with other cascading style sheets attached to the Web document.

Return Value
StyleSheet

Example

This example adds a style sheet to the active document and places it highest in the list of style sheets attached to the document. This example assumes that you have a style sheet document named Website.css located on your drive C.

Visual Basic for Applications
  Sub NewStylesheet()
    ActiveDocument.StyleSheets.Add _
        FileName:="c:\WebSite.css", _
        Precedence:=wdStyleSheetPrecedenceHighest, _
        LinkType:=wdStyleSheetLinkTypeLinked, _
        Title:="Test Stylesheet"
End Sub

See Also