StyleSheet object (Word)
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.
Remarks
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()
ActiveDocument.StyleSheets.Item(2).Delete
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"
.InsertParagraphAfter
For Each styCSS In ActiveDocument.StyleSheets
.InsertAfter styCSS.Name & vbTab & styCSS.Index
.InsertParagraphAfter
Next styCSS
.ConvertToTable
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
See also
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for