StyleSheets.Add method (Word)

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.

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

See also

StyleSheets Collection

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.