Sample Macro to Print All Styles and Their Definitions

Last reviewed: February 5, 1998
Article ID: Q140742
The information in this article applies to:
  • Microsoft Word for Windows 95, version 7.0

SUMMARY

This article provides a sample macro to list and print all styles and their definitions.

MORE INFORMATION

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

The following macro prints all styles and their definitions:

Sub MAIN
ScreenUpdating 0                          ' turn off screen noise
a = CountStyles()                         ' get # of styles, assign to
                                          ' variable
For x = 1 To a                            ' begin loop
 sn$ = StyleName$(x)
 FormatFont .Bold = 1                     ' format style name as bold
 FormatParagraph .KeepWithNext = 1        ' and keep it with style
                                          ' definition text
 Insert StyleName$(x) + Chr$(13)          ' insert style name
 FormatParagraph .KeepWithNext = 0        ' turn off Keep with Next
 FormatFont .Bold = 0                     ' turn off bold formatting
 Insert StyleDesc$(sn$) + String$(2, 13)  ' insert style definition
Next                                      ' go back for the next one
StartOfDocument                           ' go to top of document
End Sub

For additional information regarding the CountStyles() function, click Microsoft Word Help Topics on the Help menu, and see the "CountStyles() function" topic.


KBCategory: kbusage kbmacro kbhowto
KBSubcategory:
Additional reference words: count styles macro definitions 7.0 word95
countstyles word7 winword
Version : 7.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.