Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Type mismatch error

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Type mismatch error

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
---------------
Jacob Skaria


"Jive" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Type mismatch error

Thank you Jacob that works now.

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

"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"Jive" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Type mismatch error

Drop the S from that first Dim line:
Dim Piece As Shapes
should be
Dim Piece As Shape '<-- no trailing S on Shape

But there are lots of shapes that you can't move. You may want to be more
specific with your coding.

Ron de Bruin has lots of info he
http://www.rondebruin.nl/controlsobjectsworksheet.htm




Jive wrote:

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


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Type mismatch error

Ofcourse you can ... as Shape

Activesheet.Shapes is a collection

If this post helps click Yes
---------------
Jacob Skaria


"Jive" wrote:

Thank you Jacob that works now.

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

"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"Jive" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Type mismatch error


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)



On Mon, 17 Aug 2009 07:33:02 -0700, Jive
wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"