Microsoft KB Archive/81733

{|
 * width="100%"|

WD: Macro to Print Style Name Next to Each Paragraph

 * }

Q81733

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
 * Microsoft Word for Windows 95, version 7.0

-

SUMMARY
In 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 INFORMATION
Microsoft 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 professionals 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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please see the following page on the World Wide Web:

"http://www.microsoft.com/partner/referral/" For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

"http://support.microsoft.com/directory/overview.asp"

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

 * 1) From the Tools menu, choose Options.
 * 2) Select the View tab, and type a value for the Style Area Width.

Word for Windows Version 2.x

 * 1) From the Tools menu, choose Options.
 * 2) From the list of Categories, select View, and type a value for the Style Area Width.

Word for Windows Version 1.x

 * 1) From the View menu, choose Preferences.
 * 2) Type a measurement for the Style Width option.

If you want to print the style name for each paragraph, use the following macro to insert the name of each style next to each paragraph in the current document.

Microsoft Word for Windows 95, version 7.0
Sub MAIN

StartOfDocument Insert StyleName$ + &quot;>> &quot; EditFind &quot;^p&quot;, .Direction = 0           'Searches for next paragraph CharRight While EditFindFound And Not AtEndOfDocument Insert StyleName$ + &quot;>> &quot;     'Inserts the Stylename and >> EditFind &quot;^p&quot;, .Direction = 0   'Finds next Para CharRight Wend End Sub

Word for Windows Version 2.x
Sub MAIN

EndOfDocument Insert &quot; &quot;     '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 &quot;&quot;, .Direction = 2     'Searches for any occurrence of style. While EditFindFound CharLeft Insert Style$ + &quot;>> &quot;         'Inserts the Stylename and >>. EditFind &quot;&quot;, .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 &quot; &quot;     '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 = &quot;^y &quot; + Style$, .Direction = 2 'Searches for style.

While EditSearchFound CharLeft Insert Style$ + &quot;>> &quot;         'Inserts the Stylename and >>. EditSearch .Search = &quot;^y &quot; + 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