Adding Shapes: Position changes when running code a second time - Why?

R

Richard Buttrey

Hi,

I have some code which adds about 10 shapes (rounded rectangles), to a
sheet. When I delete the shapes and run the code a second time,
sometimes the shapes are in the same position, but sometimes they have
dropped down the page a few rows. It doesn't appear consistent, and
I'm puzzled since of course the code contains the same positioning
parameters. i.e. Left, Top, Depth, Width.

Can anyone suggest what causes this?

Regards and usual TIA



__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 
D

Dave Peterson

Depth???

Do you have the zoom set to 100%?

Richard said:
Hi,

I have some code which adds about 10 shapes (rounded rectangles), to a
sheet. When I delete the shapes and run the code a second time,
sometimes the shapes are in the same position, but sometimes they have
dropped down the page a few rows. It doesn't appear consistent, and
I'm puzzled since of course the code contains the same positioning
parameters. i.e. Left, Top, Depth, Width.

Can anyone suggest what causes this?

Regards and usual TIA

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 
R

Richard Buttrey

Thanks Mike

Here's the Procedure which defines the parameters. Below it is the
code which draws the picture. All the variables (iTop, iwidth etc.)
are module level DIM variables, and there's one variable which is
passed as a parameter in the Call DrawFixture.FormatShapes() procedure

Sub AddShapes()
iScale = 10
iTop = 100

Worksheets("Bay Design").Activate: Range("A1").Select
For x = 1 To Range("totalBays")
iLeft = 100
If Range("BayTop").Offset(x + 3, 2) <> "" Then
iwidth = Range("BayTop").Offset(x + 3, 2) / iScale
idepth = Range("BayTop").Offset(x + 3, 3) / iScale
stBayRef = Range("BayTop").Offset(x + 3, 1) & " : " & _
Range("BayTop").Offset(x + 3, 13)
Call DrawFixture.FormatShapes(iLeftlastwidth)
iLeftlastwidth = iLeftlastwidth + idepth

ElseIf Range("BayTop").Offset(x + 3, 4) <> "" Then
iLeft = 100 + Range("RHBayPos") / iScale
iwidth = Range("BayTop").Offset(x + 3, 4) / iScale
idepth = Range("BayTop").Offset(x + 3, 5) / iScale
stBayRef = Range("BayTop").Offset(x + 3, 1) & " : " & _
Range("BayTop").Offset(x + 3, 13) ' & _
Chr(10) & "W: " & Range("BayTop").Offset(X + 3,
4) & Chr(10) & "D: " & Range("BayTop").Offset(X + 3, 5)
Call DrawFixture.FormatShapes(iRightlastwidth)
iRightlastwidth = iRightlastwidth + idepth
End If

Next x
Range("A1").Select

End Sub


Sub FormatShapes(iBayOffset As Integer)
ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, _
iLeft, iTop + iBayOffset, iwidth, idepth).Select

'Other formatting code below not shown
End Sub

Kind regards


Richard Buttrey -

I suggest you post your code, at least the portion that positions the
shapes.

- Mike Middleton
http://www.DecisionToolworks.com
Decision Analysis Add-ins for Excel

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top