changing size of autoshape

  • Thread starter Thread starter grime
  • Start date Start date
G

grime

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
 
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
 
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
 
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
 
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 said:
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
 

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

Back
Top