Hi there. I need to print out a very long document and
then go through it and put the names of all the styles
used next to the paragraphs. I don't suppose there is
anyway I could just tell the computer to print all the
style names?
Thanks for any advice.
Carol NS
The following macro will insert the style at the end of each paragraph.
Dim apara As Paragraph, prange As Range
For Each apara In ActiveDocument.Paragraphs
Set prange = apara.Range
prange.End = prange.End - 1
prange.InsertAfter " - " & apara.Style
Next apara

Signature
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
> Hi there. I need to print out a very long document and
> then go through it and put the names of all the styles
[quoted text clipped - 3 lines]
> Thanks for any advice.
> Carol NS
Dayo Mitchell - 07 Apr 2004 10:05 GMT
Alternatively, when you go to print, the print dialog box should have a
Print: or Print What? Dropdown menu, which you can set to styles, and it
will print a list of styles.
DM
> The following macro will insert the style at the end of each paragraph.
>
[quoted text clipped - 12 lines]
>> Thanks for any advice.
>> Carol NS
Carol NS - 09 Apr 2004 10:50 GMT
Mr Robbins, thank you for the macro. Just one thing: it's
tells me when I run it: "Run time error 5251: not a valid
action for the end of a row".
In the New Macros (Code) window, the line
prange.InsertAfter " - " & apara.Style
is highlighted.
I apologise if I'm doing something obviously wrong here -
it's the first time I've done one of these. (I used
the "What do I do with macros other users send me"
article).
Carol NS
>-----Original Message-----
>The following macro will insert the style at the end of each paragraph.
[quoted text clipped - 15 lines]
>
>.
Doug Robbins - Word MVP - 09 Apr 2004 13:46 GMT
That would be because you have tables in the document. The following
modified code will skip the tables:
Dim apara As Paragraph, prange As range
For Each apara In ActiveDocument.Paragraphs
Set prange = apara.range
prange.End = prange.End - 1
If Not prange.Information(wdWithInTable) Then
prange.InsertAfter " - " & apara.Style
End If
Next apara
or, the following will just ignore that error message and insert the style
after the paragraphs in the table as well:
Dim apara As Paragraph, prange As range
On Error Resume Next
For Each apara In ActiveDocument.Paragraphs
Set prange = apara.range
prange.End = prange.End - 1
prange.InsertAfter " - " & apara.Style
Next apara

Signature
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
> Mr Robbins, thank you for the macro. Just one thing: it's
> tells me when I run it: "Run time error 5251: not a valid
[quoted text clipped - 38 lines]
>>
>>.
Carol NS - 10 Apr 2004 23:38 GMT
Problem solved. Thank you VERY much.
>-----Original Message-----
>That would be because you have tables in the document. The following
[quoted text clipped - 64 lines]
>
>.