StyleSheet Object (Word)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents a single cascading style sheet attached to a Web document. The StyleSheet object is a member of the StyleSheets collection. The StyleSheets collection contains all the cascading style sheets attached to a specified document.

Use the Item method or StyleSheets(Index), where Index is the name or number of the style sheet, of the StyleSheets collection to return a StyleSheet object. The following example removes the second style sheet from the StyleSheets collection.

Sub WebStyleSheets() 
End Sub

Use the Index property to determine the precedence of cascading style sheets. The following example creates a table of attached cascading style sheets, ordered and indexed according to which style sheet is most important.

Sub CSSTable() 
 Dim styCSS As StyleSheet 
 With ActiveDocument.Range(Start:=0, End:=0) 
 .InsertAfter "CSS Name" & vbTab & "Index" 
 For Each styCSS In ActiveDocument.StyleSheets 
 .InsertAfter styCSS.Name & vbTab & styCSS.Index 
 Next styCSS 
 End With 
End Sub

Use the Move method to reorder the precedence of attached style sheets. The following example moves the most important style sheet to the least important of all attached cascading style sheets.

Sub MoveCSS() 
 ActiveDocument.StyleSheets(1) _ 
 .Move wdStyleSheetPrecedenceLowest 
End Sub