Margin Text

Home Up Odds & Ends Photo Gallery Search Contact Me

 

 

The information in this website is provided without risk or obligation and free of charge.  However, if you have benefitted from my efforts here and would like to make a contribution to help me continue and maintain this work then any donation will be greatly appreciated. Please click the adjacent button to access PayPal.  Thank you.
 

Users often ask how they can place headings, notes, or other text in the page margins.  MVP Suzanne Barnhill offers a comprehensive discussion on this topic in her tutorial Marginal Text.  One of the methods that she proposes is a margin text style.  This can be fiddly (Suzanne's own words) to set up.

I second Suzanne's assessment.  I tried setting up a similar style (without her tutorial) and struggled considerably.  After that I thought,  why not use a macro to do the dirty work?  Once a basic Margin Text style is set up it is a cinch to edit and refine to an individual user's taste.  After all it is a style and all styles are easily modified.

Here is the code:

 

Sub MarginTextStyle()
Dim styleName As String
Dim oStyle As Style

styleName = "Margin Text"
'Create/Setup the style
For Each oStyle In ActiveDocument.Styles
  If oStyle.NameLocal = styleName Then GoTo Setup
Next oStyle
ActiveDocument.Styles.Add Name:=styleName, Type:=wdStyleTypeParagraph
Setup:
With ActiveDocument.Styles(styleName)
  .AutomaticallyUpdate = False
  .BaseStyle = ""
  .NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles(styleName).Font
  .Size = 8
  .ColorIndex = wdAuto
End With
With ActiveDocument.Styles(styleName).ParagraphFormat
  .LineSpacingRule = wdLineSpaceSingle
  .WidowControl = False
  .KeepWithNext = True
  .KeepTogether = True
  .OutlineLevel = wdOutlineLevelBodyText
  .Shading.BackgroundPatternColor = wdColorLightYellow
  With .Borders
    .OutsideLineStyle = wdLineStyleSingle
    .OutsideLineWidth = wdLineWidth050pt
    .OutsideColor = wdColorAutomatic
    .DistanceFromTop = 1
    .DistanceFromLeft = 1
    .DistanceFromBottom = 1
    .DistanceFromRight = 1
    .Shadow = False
  End With
End With
With ActiveDocument.Styles(styleName).Frame
  .TextWrap = True
  .WidthRule = wdFrameExact
  .Width = 66
  .HeightRule = wdFrameAuto
  .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
  .RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
  .HorizontalDistanceFromText = InchesToPoints(0.08)
  .VerticalDistanceFromText = InchesToPoints(0)
  .LockAnchor = False
End With
End Sub

 

 
See:  Idiots' guide to installing macros from newsgroup listings at fellow MVP Graham Mayor's website for instructions on how to install macros. 
After running the macro your template will contain a new style  "Margin Text"
 

 

The settings I have used in the macro creates the bordered and shaded frames shown above.  Remember the macro creates a style.  If you don't like this look then all you need to do is redefine the style just like any other style used in Word.

Looking for something else?

Google