ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   changing size of autoshape (https://www.excelbanter.com/excel-programming/351444-changing-size-autoshape.html)

grime[_14_]

changing size of autoshape
 

Trying to do some basic animation with an autoshape. I have a rectangle
that I am changing the size in steps. The problem is, it resizes the
bottom edge of the rectangle up instead of moving the top edge of the
rectangle down.

here is my code:

Code:
--------------------
For j = 1 To 200
rectheight = rectheight - 0.5
ActiveSheet.Shapes("Rectangle 1").Height = rectheight
For i = 1 To 100
DoEvents
Next i
Next j
--------------------


How do I tell VBA to resize my rectangle from the bottom up?


--
grime
------------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504923


Tom Ogilvy

changing size of autoshape
 
ltop = ActiveSheet.shapes("Rectangle 1").Top
For j = 1 To 200
rectheight = rectheight - 0.5
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rectangle 1").Height = rectheight
Activesheet.Shapes("Rectangle 1").Top = lTop
Application.ScreenUpdating = True
For i = 1 To 100
DoEvents
Next i
Next j

--
Regards,
Tom Ogilvy


"grime" wrote in
message ...

Trying to do some basic animation with an autoshape. I have a rectangle
that I am changing the size in steps. The problem is, it resizes the
bottom edge of the rectangle up instead of moving the top edge of the
rectangle down.

here is my code:

Code:
--------------------
For j = 1 To 200
rectheight = rectheight - 0.5
ActiveSheet.Shapes("Rectangle 1").Height = rectheight
For i = 1 To 100
DoEvents
Next i
Next j
--------------------


How do I tell VBA to resize my rectangle from the bottom up?


--
grime
------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504923




grime[_15_]

changing size of autoshape
 

My bad. I contradicted myself in my post.

As I resize the rectangle, I want the bottom edge to stay in place an
have the top edge move. Your code keeps the top edge aligned

--
grim
-----------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...fo&userid=1922
View this thread: http://www.excelforum.com/showthread.php?threadid=50492


Tom Ogilvy

changing size of autoshape
 
My mistake in reading.

ltop = ActiveSheet.shapes("Rectangle 1").Top
For j = 1 To 200
rectheight = rectheight - 0.5
ltop = ltop - 0.5
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rectangle 1").Height = rectheight
Activesheet.Shapes("Rectangle 1").Top = lTop
Application.ScreenUpdating = True
For i = 1 To 100
DoEvents
Next i
Next j

--
Regards,
Tom Ogilvy


"grime" wrote in message
...

My bad. I contradicted myself in my post.

As I resize the rectangle, I want the bottom edge to stay in place and
have the top edge move. Your code keeps the top edge aligned.


--
grime
------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504923




Tom Ogilvy

changing size of autoshape
 
whoops, should be incrementing the top

ltop = ActiveSheet.shapes("Rectangle 1").Top
For j = 1 To 200
rectheight = rectheight - 0.5
ltop = ltop + 0.5
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rectangle 1").Height = rectheight
Activesheet.Shapes("Rectangle 1").Top = lTop
Application.ScreenUpdating = True
For i = 1 To 100
DoEvents
Next i
Next j

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
My mistake in reading.

ltop = ActiveSheet.shapes("Rectangle 1").Top
For j = 1 To 200
rectheight = rectheight - 0.5
ltop = ltop - 0.5
Application.ScreenUpdating = False
ActiveSheet.Shapes("Rectangle 1").Height = rectheight
Activesheet.Shapes("Rectangle 1").Top = lTop
Application.ScreenUpdating = True
For i = 1 To 100
DoEvents
Next i
Next j

--
Regards,
Tom Ogilvy


"grime" wrote in

message
...

My bad. I contradicted myself in my post.

As I resize the rectangle, I want the bottom edge to stay in place and
have the top edge move. Your code keeps the top edge aligned.


--
grime
------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread:

http://www.excelforum.com/showthread...hreadid=504923






grime[_16_]

changing size of autoshape
 

Yer the man, Tom. Thanks a ton.


--
grime
------------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504923



All times are GMT +1. The time now is 11:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com