I've accomplished this already by using two less than
desirable methods: by putting the style labels in text
boxes and by converting the document to a table with
style labels in one column, paragraph text in the
adjacent column. I'm finding that using text boxes are
unpredictable on different machines and using a table is
slower than molasses.
So is anyone aware of a better way to do this? You'd
think Word (2002) would have this as a built in feature
since if it's useful to show style labels in the document
window, it stands to reason that it might be useful to
display them on hard copy. One for the wish list?
Thanks,
Pat L
Something like the following code might be what you're looking for. Please
not that the code as written makes at least a few assumptions. The ones
that come to mind are that 1 inch will be sufficient space for all your
style names and that your left margin is at least 1 inch wide.
Sub StyleNames()
Dim oStyle As Style
Dim oNormal As Style
Dim oSec As Section
Dim oPar As Paragraph
Dim oRng As Range
Set oStyle = ActiveDocument.Styles.Add(Name:="StyleName",
Type:=wdStyleTypeParagraph)
Set oNormal = ActiveDocument.Styles("Normal")
With oStyle
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "StyleName"
.Font = oNormal.Font.Duplicate
.ParagraphFormat = oNormal.ParagraphFormat.Duplicate
.ParagraphFormat.Alignment = wdAlignParagraphRight
With .Frame
.TextWrap = True
.WidthRule = wdFrameExact
.Width = InchesToPoints(1)
.HeightRule = wdFrameAuto
.HorizontalPosition = wdFrameLeft
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.VerticalPosition = InchesToPoints(0)
.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
.HorizontalDistanceFromText = InchesToPoints(0.13)
.VerticalDistanceFromText = InchesToPoints(0)
.LockAnchor = False
End With
End With
For Each oPar In ActiveDocument.Paragraphs
Set oRng = oPar.Range
If oRng.Tables.Count = 0 Then
With oRng
.InsertBefore Text:=oPar.Style & vbCr
.Collapse Direction:=wdCollapseStart
.Style = "StyleName"
.ParagraphFormat.SpaceBefore = oPar.SpaceBefore
End With
End If
Next oPar
MsgBox Prompt:="done"
End Sub
Hope that helps
Regards,
Chad
"Pat L" <anon...@discussions.microsoft.com> wrote in message
news:46ee01c47fd6$c7501660$a601...@phx.gbl...
Haven't tried... but maybe you could use a framed style in the left margin.
Each other paragraph would be in that style, and contain the name of the
style of the next paragraph.
They would be inserted by some macro.
You could hide the paragraphs in this framed style by re-defining the style
as hidden, and could delete the paragraphs with Find/Replace (... search
for the style, replace with nothing).
> One for the wish list?
Doesn't hurt to write to
http://register.microsoft.com/mswish/suggestion.asp
:-) Klaus
Thanks for your help. Your suggestion is similar to my
current solution using text boxes, but I will test yours
to see what improvements it offers.
Thanks again.
Pat
>.
>
>.
>