View Single Post
  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default Draw a Double Line in Word 2007?

On Sep 18, 7:07*pm, Lene Fredborg
wrote:
I found out that even if the four double/tripple line styles known from
previous Word versions are not available in the user interface in Word 2007,
you have access to the line styles via VBA – and this means that you can use
a macro to apply a double/tripple line style. As Greg said, once you have
such line in a Word 2007 document, you can change the line style of that line
to one of the other double/tripple line styles via the Format AutoShape
dialog box.

The macro below creates a 5 cm long horizontal line and applies the “two
thin lines” line style (the remaining line styles are listed below the
macro). For further details, see the comments in the macro.

--------------------
Sub AddLineShape_DoubleLineStyle()

* * Dim oShape As Shape
* * Dim nStartHor As Single
* * Dim nStartVer As Single

* * 'Find the point where the top and left margins intersect
* * 'Use this point as the starting point for the line
* * nStartHor = ActiveDocument.PageSetup.LeftMargin
* * nStartVer = ActiveDocument.PageSetup.TopMargin

* * With ActiveDocument
* * * * 'Create a vertical line, length 5 cm
* * * * Set oShape = .Shapes.AddLine(nStartHor, nStartVer, nStartHor +
CentimetersToPoints(5), nStartVer)
* * * * With oShape
* * * * * * .Line.Style = msoLineThinThin
* * * * * * .Line.Weight = 3
* * * * End With
* * End With

* * 'Clean up
* * Set oShape = Nothing
End Sub

--------------------
To apply one of the other double (or tripple) line styles, replace the code
lines:

* * * * * * .Line.Style = msoLineThinThin
* * * * * * .Line.Weight = 3

with the appropriate set of lines below:

* * * * * * .Line.Style = msoLineThinThick
* * * * * * .Line.Weight = 4.5

or

* * * * * * .Line.Style = msoLineThickThin
* * * * * * .Line.Weight = 4.5

or

* * * * * * .Line.Style = msoLineThickBetweenThin
* * * * * * .Line.Weight = 4.5

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word



"Suzanne S. Barnhill" wrote:
Yes, I had already seen that reply.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org


"Greg Maxey" wrote in message
...
Take a look at my reply to Ryan. *If you use fancy line segments you can
put together a crude work around as long as you have access to a Word2003
document containing a line segment.


Suzanne S. Barnhill wrote:
Oh, that's good news, at least for those of us still running Word
2003 and 2007 side by side.


"Greg Maxey" wrote in
. ..
Ms. Barnhill,


Actually the option is disabled for line segments drawn with
Word2007. The option is still available and enabled for line
segments drawn with Word2003.


Suzanne S. Barnhill wrote:
Unfortunately, the Line Style option for drawing lines was removed
from Word 2007.


"Ryan" wrote in message
...
I've pulled my hair out many times trying to use this pos Office
2007. One
of the annoyances was trying to draw a double line.


I draw a line, right-click, select Format Autoshape, then try to
change the
Style to a double-line, but it's greyed out.


Any ideas?


And if you'll allow me to rant a little bit, I just want to use
Word... this
new interface is tedious and time consuming. *I don't want to fart
around with a ribbon, just give me a menu bar.


Ryan


--
Greg Maxey


See my web sitehttp://gregmaxey.mvps.org
for an eclectic collection of Word Tips.


"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - *TR


--
Greg Maxey


See my web sitehttp://gregmaxey.mvps.org
for an eclectic collection of Word Tips.


"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - *TR- Hide quoted text -


- Show quoted text -


Lene,

Nice sluething ;-) Since the line built with VBA is fully formattable
(i.e., style is enabled). I would do it like this and then edit the
line segment by selecting it and formatting autoshape:

Sub BuildFullyFormatableLine()
Dim oShp As Word.Shape
Dim i As Long
Dim j As Long
i = Selection.Information(wdVerticalPositionRelativeTo Page)
j = Selection.Information(wdHorizontalPositionRelative ToPage)
'Add a one inch long horizontal line segment at the selection.
Set oShp = ActiveDocument.Shapes.AddLine(i, j, i + 72, j)
With oShp.Line
.Style = msoLineSingle
.Weight = 0.75
End With
Set oShp = Nothing
End Sub