Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Collapsing and Expanding Subdocuments
Converting Word for DOS Documents
Two Keys with the Press of One
Dave would love a way to print a full-featured style sheet for his documents. He knows that he can choose to print "Styles" in the Print dialog box, but he would rather have a style sheet that shows the actual styles, such as color, size, font, etc.
Unfortunately there is no such capability in Word. You can, however, create a style sheet of your liking by using a macro. For instance, the following will insert, in the current document, the names of all the styles available in the document. Each style name is on its own line (paragraph) and is formatted using the various styles.
Sub ListStyleNames()
For Each Style In ActiveDocument.Styles
With Selection
.Style = ActiveDocument.Styles(Style)
.TypeText (ActiveDocument.Styles(Style).NameLocal)
.TypeParagraph
End With
Next
End Sub
Such an approach, while handy for a concise list of styles, isn't much more informative than what can be printed using the "Styles" designation in the Print dialog box. It does, however, provide a basis upon which one can build to create a more full-featured style sheet.
The problem with creating a detailed style sheet using macros is that styles can contain a ton of information. The object model used by Word (and accessible in VBA) quickly becomes quite complex when testing styles to see what they contain. Here's just a simple example to give you the flavor:
Sub SimpleStyleSheet()
Dim sOutput As String
Dim sTemp As String
Dim StyleTypes(4) As String
StyleTypes(1) = "Paragraph"
StyleTypes(2) = "Character"
StyleTypes(3) = "Table"
StyleTypes(4) = "List"
For Each Style In ActiveDocument.Styles
sOutput = Style.NameLocal & vbCrLf
sOutput = sOutput & " Style type: " & StyleTypes(Style.Type) & vbCrLf
sTemp = Style.BaseStyle
If Len(sTemp) > 0 Then
sOutput = sOutput & " Based on: " & Style.BaseStyle & vbCrLf
End If
sOutput = sOutput & " Font: " & Style.Font.Name
sTemp = ""
If Style.Font.Bold Then sTemp = sTemp & "Bold, "
If Style.Font.Italic Then sTemp = sTemp & "Italic, "
If Len(sTemp) > 0 Then
sTemp = Left(sTemp, Len(sTemp) - 2)
sOutput = sOutput & " (" & sTemp & ")"
End If
sOutput = sOutput & vbCrLf
Selection.TypeText (sOutput & vbCrLf)
Next
End Sub
The only thing this macro does is to list all the styles, what type of styles they are, whether they are based on a different style (and if so, what that style is named), what font is used by the style, and whether the font is bold or italic. Anyone familiar with styles will immediately understand that these few items are only a small sampling of what can be defined within a style. To check all possible style formats and print them in the style sheet would make the macro very long, indeed.
Even so, this macro might be useful as it provides an idea of how to put together your own style sheet. You just need to figure out what you want to see in the style sheet and then add the macro code to determine that information and print it out.
Tip #6748 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Tremendous Table Tips! We often take tables for granted, but Word includes some very powerful ways you can present your tabular data. Discover how to make your tables better, easier to understand, and more effective.