Problem width width-property

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi

I'd like to change a line (shapes-object). This works fine when line goes
from up-left to down-right, but I'm not able to draw a line from up-right to
down-left. In this case the width-property would be minus, but this is not a
valid value. How to do?

Tom
 
1. You can delete the line and redraw it.
2. You can record a macro & change the line to see how Excel does it. I did
it I couldn't figure it out.

I think option 1 is easier.
 
I added 2 lines from the drawing toolbar on to a fresh worksheet. I could
manipulate the existing lines by going through the Lines collection or the
Shapes collection.

Maybe there's something in here that helps:

Option Explicit
Sub testme01()
Dim myLine1 As Line
Dim myLine2 As Shape
Dim myLine3 As Shape
Dim myLine4 As Line

With ActiveSheet
Set myLine1 = .Lines("Line 1")
myLine1.ShapeRange.Flip msoFlipHorizontal

Set myLine2 = .Shapes("line 2")
myLine2.Flip msoFlipVertical

With .Range("b3:c9")
Set myLine3 = .Parent.Shapes.AddLine _
(beginx:=.Left, _
beginy:=.Top, _
endx:=.Left + .Width, _
endy:=.Top + .Height)

'myLine3.Flip msoFlipHorizontal
myLine3.Name = "Line 3"
End With

With .Range("e3:g9")
Set myLine4 = .Parent.Lines.Add _
(x1:=.Left, _
y1:=.Top, _
x2:=.Left + .Width, _
y2:=.Top + .Height)

'myLine4.Flip msoFlipHorizontal
myLine4.Name = "Line 4"
End With
End With
End Sub

the Lines stuff is a hold over from xl95. They're a "hidden" element of xl97
and greater. You can still find info within the Object browser if you want.
But I'd recommend that you use the shapes collection. You'll be able to get
help out of VBA's help system.
 
Back
Top