gmaxey
09-25-2009, 05:00 AM
There is a problem line drawing object drawn with Word2007. When these objects are drawn using the UI, the style attribute is disabled.
Lines drawn in Word2003 and pasted into Word2007 can be fully formatted (style enabled) in the UI. Also lines created in Word2007 using VBA can be fully formatted in the UI.
I have put together some code intended to duplicate and replace a line drawn using the UI as a line that can be fully formatted. I draw the line in the document with the UI, select it, and then run this code:
Sub DuplicateAndReplaceLine()
Dim oShp As Word.Shape
Dim oShpNew As Word.Shape
Dim i, j, k, l As Long
Set oShp = Selection.ShapeRange(1)
i = oShp.Left
j = oShp.Top
k = oShp.Height
l = oShp.Width
oShp.Delete
Set oShpNew = ActiveDocument.Shapes.AddLine(i, j, i + 72, j)
With oShpNew
.Left = i
.Top = j
.Width = l
.Height = k
With .Line
.Style = msoLineSingle
.Weight = 0.75
End With
End With
End Sub
It works provided the line is vertical, horizontal or slopes left to
right down the page.
The problem is lines that slope rigth to left down the page appear as a mirror image of the original line and slope left to right down the page.
I could easily fix this using flip, but I can't figure out how to tell (at runtime) if the line will need flipping.
Does anyone have any ideas how to determine the direction of slope for a line drawing or the corridinates of the line start and end points.
Thanks.
Lines drawn in Word2003 and pasted into Word2007 can be fully formatted (style enabled) in the UI. Also lines created in Word2007 using VBA can be fully formatted in the UI.
I have put together some code intended to duplicate and replace a line drawn using the UI as a line that can be fully formatted. I draw the line in the document with the UI, select it, and then run this code:
Sub DuplicateAndReplaceLine()
Dim oShp As Word.Shape
Dim oShpNew As Word.Shape
Dim i, j, k, l As Long
Set oShp = Selection.ShapeRange(1)
i = oShp.Left
j = oShp.Top
k = oShp.Height
l = oShp.Width
oShp.Delete
Set oShpNew = ActiveDocument.Shapes.AddLine(i, j, i + 72, j)
With oShpNew
.Left = i
.Top = j
.Width = l
.Height = k
With .Line
.Style = msoLineSingle
.Weight = 0.75
End With
End With
End Sub
It works provided the line is vertical, horizontal or slopes left to
right down the page.
The problem is lines that slope rigth to left down the page appear as a mirror image of the original line and slope left to right down the page.
I could easily fix this using flip, but I can't figure out how to tell (at runtime) if the line will need flipping.
Does anyone have any ideas how to determine the direction of slope for a line drawing or the corridinates of the line start and end points.
Thanks.