Type mismatch error

J

Jive

Hi I am getting a type mismatch error back on line 2 of the script below. I
have already made a workaround but this is a much neater way of getting the
code to work if i can. I lack understanding of this method and have only
applied it in a couple cases before now so any help would be much appreciated.

Dim Piece As Shapes
For Each Piece In ActiveSheet.Shapes
CurrentTop = Piece.Top
CurrentLeft = Piecee.Left
Piece.Top = 540 - CurrentTop
Piece.Left = 540 - CurrentLeft
Next Piece
 
J

Jacob Skaria

You should be referring to the object as below

Dim Piece As Object
For Each Piece In ActiveSheet.Shapes
CurrentTop = Piece.Top
CurrentLeft = Piece.Left
Piece.Top = 540 - CurrentTop
Piece.Left = 540 - CurrentLeft
Next Piece

If this post helps click Yes
 
J

Jive

Thank you Jacob that works now.

I know a shape is an object but why cant i refer to it as a shape?
 
J

Jacob Skaria

Ofcourse you can ... as Shape

Activesheet.Shapes is a collection

If this post helps click Yes
 
C

Chip Pearson

Dim Piece As Shapes

should be

Dim Piece As Shape ' singular, not plural

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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

Similar Threads


Top