WD: Word: Macro to Print Style Name Next to Each ParagraphLast reviewed: January 30, 1998Article ID: Q81733 |
The information in this article applies to:
SUMMARYIn Microsoft Word, you can display the style names used in a document as a view option only. There is no built-in feature that inserts the style name of each paragraph next to that paragraph and print out that information.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/supportnet/refguide/Word has a Style Area Width option that opens a style name area on the left side of a document window to display style names. This option is for on- screen viewing only. The style names do not appear in print preview, and they do not print. To display the name of each style used in a document for display purposes only, use the appropriate method for your version of Word.
Word for Windows Version 6.x
Word for Windows Version 2.x
Word for Windows Version 1.x
Word for Windows Version 6.x Word for the Macintosh 6.0, 6.0.1
Sub MAIN
StartOfDocument
Insert StyleName$() + ">> "
EditFind "^p", .Direction = 0 'Searches for next paragraph
CharRight
While EditFindFound() And Not AtEndOfDocument()
Insert StyleName$() + ">> " 'Inserts the Stylename and >>
EditFind "^p", .Direction = 0 'Finds next Para
CharRight
Wend
End Sub
Word for Windows Version 2.x
Sub MAIN
EndOfDocument
Insert " " 'Error trap in case no text in last paragraph.
num = CountStyles() 'Counts the number of current styles.
For x = 1 To num
StartOfDocument
Style$ = StyleName$(x) 'Finds the name of the Style number.
EditFindStyle .Style = Style$ 'Sets the search up for the style.
EditFind "", .Direction = 2 'Searches for any occurrence of style.
While EditFindFound()
CharLeft
Insert Style$ + ">> " 'Inserts the Stylename and >>.
EditFind "", .Direction = 2 'Finds next Para with the stylename.
Wend
Next x 'goes to the next style
EndOfDocument
EditClear -1 'Removes space inserted to avoid endless loop.
End Sub
Word for Windows Version 1.x
Sub MAIN
EndOfDocument
Insert " " 'Error trap in case no text in last paragraph.
num = CountStyles() 'Counts the number of current styles.
For x = 1 To num
StartOfDocument
Style$ = StyleName$(x) 'Finds the name of the Style number.
EditSearch .Search = "^y " + Style$, .Direction = 2 'Searches for style.
While EditSearchFound()
CharLeft
Insert Style$ + ">> " 'Inserts the Stylename and >>.
EditSearch .Search = "^y " + Style$, .Direction = 2 'Finds next.
Wend
Next x 'Goes to the next style.
EndOfDocument
EditClear -1 'Removes space inserted to avoid endless loop.
End Sub
REFERENCES"Microsoft Word for Windows User's Guide," version 2.0, page 729
|
Additional query words: winword2
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |