PC Review


Reply
Thread Tools Rate Thread

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

 
 
Richard Buttrey
Guest
Posts: n/a
 
      21st Feb 2008
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
__________________________
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      21st Feb 2008
Depth???

Do you have the zoom set to 100%?

Richard Buttrey wrote:
>
> 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
> __________________________


--

Dave Peterson
 
Reply With Quote
 
Mike Middleton
Guest
Posts: n/a
 
      21st Feb 2008
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" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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
> __________________________



 
Reply With Quote
 
Richard Buttrey
Guest
Posts: n/a
 
      21st Feb 2008
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


On Wed, 20 Feb 2008 23:16:22 -0800, "Mike Middleton"
<(E-Mail Removed)> wrote:

>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" <(E-Mail Removed)> wrote in
>message news:(E-Mail Removed)...
>> 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
>> __________________________

>
>


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position shapes to be centered in a cell James Microsoft Excel Programming 2 16th Sep 2009 03:46 PM
Code to delete shapes each time a sheet is deactivated Rick Rothstein \(MVP - VB\) Microsoft Excel Programming 2 4th Nov 2007 12:51 PM
Adding customized shapes to shapes toolbar =?Utf-8?B?amFtZXNfY2hpbGxp?= Microsoft Powerpoint 2 24th Jul 2007 04:16 AM
Shapes XY position in VBA (setting and reading) =?Utf-8?B?Zmx5aW5nX3BpZw==?= Microsoft Powerpoint 1 2nd Jan 2007 12:51 PM
Adding Total Running Time from Begining and Ending Time david.tiberia@publix.com Microsoft Access Form Coding 2 14th Feb 2006 08:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:46 AM.