Fancy Lines Word2007

Home Up Odds & Ends Photo Gallery Search Contact Me Privacy Notice What's New?

 

 

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.
 
The purpose of this Microsoft Word Tips & Microsoft Word Help page is to show you how to access and use the "fancy" line drawing styles that were available in previous Word versions in in your Word2007 documents.  When you draw a line using Word2003, you can select that line, select "Format AutoShape..." and add a little flair to the line by apply one of several available line styles.  

For whatever reason, the developers of Word2007 apparently didn't like that feature and tried to take it away.  When you draw a line in Word2007 and attempt those same steps you are met with a disabled style attribute box.   Click the Insert Tab>Illustrations Group>Shapes>Lines>Basic line and draw a line in the document.

Select and right click the line then select "Format AutoShape...."  The style attribute is disabled.

Fortunately the developers where not very thorough in their attempt to execute this feature.  A drawing line inserted with VBA can be fully formatted as the following illustration will show.  Insert a "fancy" line into a Word2007 document using the following macro:

Sub InsertFancyLineWithVBA()
Dim oShp As Word.Shape
Set oShp = ActiveDocument.Shapes.AddLine(25, 25, 100, 100)
With oShp.Line
  .Style = msoLineThickBetweenThin
  .Weight = 6
End With
End Sub

The formatted line is inserted.  Better yet, it can now be fully formatted using the "Format AutoShape..." style attribute.

:old: The same behavior is observed when a basic line is inserted using VBA or if a line drawn with Word2003 is copy and pasted in a Word2007 document.

Through a bit of VBA manipulation any of the three basic line shapes (basic, arrow, double arrow) drawn with the user interface in Word2007 can be converted by selecting the line and running the following macro.  Lines converted in this manner can then be fully formatted using the "Format AutoShape..." style attribute.

Sub DuplicateAndReplaceLine()
'Declare variables
Dim oShp As Word.Shape
Dim bHFlip As Boolean
Dim bVFlip As Boolean
Dim oShpNew As Word.Shape
Dim i As Long, j As Long, k As Long, l As Long
Dim lngBAL As Long, lngBAS As Long, lngBAW As Long
Dim lngEAL As Long, lngEAS As Long, lngEAW As Long
Dim lngStyle As Long
Dim pWeight As String
'Get the cooridates and attributes of the selected line
Set oShp = Selection.ShapeRange(1)
i = oShp.Left
j = oShp.Top
k = oShp.Height
l = oShp.Width
bHFlip = oShp.HorizontalFlip
bVFlip = oShp.VerticalFlip
With oShp.Line
    lngStyle = .Style
    pWeight = .Weight
    lngBAL = .BeginArrowheadLength
    lngBAS = .BeginArrowheadStyle
    lngBAW = .BeginArrowheadWidth
    lngEAL = .EndArrowheadLength
    lngEAS = .EndArrowheadStyle
    lngEAW = .EndArrowheadWidth
End With
'Delete the line
oShp.Delete
'Recreate the line as a fully formattable VBA inserted line
Set oShpNew = ActiveDocument.Shapes.AddLine(i, j, i + 72, j)
With oShpNew
    .Left = i
    .Top = j
    .Width = l
    .Height = k
    If .HorizontalFlip <> bHFlip Then .Flip (msoFlipHorizontal)
    If .VerticalFlip <> bVFlip Then .Flip (msoFlipVertical)
    With .Line
       .Style = lngStyle
       .Weight = pWeight
       .BeginArrowheadLength = lngBAL
       .BeginArrowheadStyle = lngBAS
       .BeginArrowheadWidth = lngBAW
       .EndArrowheadLength = lngEAL
       .EndArrowheadStyle = lngEAS
       .EndArrowheadWidth = lngEAW
   End With
End With
End Sub

Special thanks to friend and Word MVP Tony Jollans for assisting with the line flip replication in this procedure.

See: Installing Macros for instructions on how to set up and use the macro listed above.

Add the DuplicateAndReplaceLine macro to your Quick Access Toolbar (QAT) or see Keyboard Shortcut for instructions on how to run a macro with a keyboard shortcut.


Looking for something else?

Google