The Anchorage
Personal website of Gregory K. Maxey, Commander USN (Retired)
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!
The purpose of this Microsoft Word Tips & Microsoft Word Help page is show you how you can restore the "fancy" (or compound) line shape capability in Word 2007 documents.
The following depicts a compound line shape drawn in using Word 2003.
1 | 2 |
3 | 4 |
For whatever reason, the developers of Word 2007 apparently didn't like that feature and tried to take it away. When you draw a line in Word 2007 and attempt those same steps you are met with a disabled style attribute box.
Note: To insert a basic line in Word 2007, use Insert tab>Illustrations Group>Shapes>Lines.
Fortunately, the developers were not very thorough in their attempt to execute this feature. A drawing line inserted with VBA can include style elements including a "fancy" line.
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 lbl_Exit: Exit Sub End Sub
The line inserted using the VBA procedure can fully formatted using the now enabled style attribute.
Note: Lines drawn with Word 2003 and pasted in a Word 2007 document behave similarly.
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 lbl_Exit: Exit Sub End Sub
Note: In the Word 2010 drawing object model this feature is restored using the line style "Compound Line" attribute.
That's it! I hope you have found this tips page useful and informative.
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!