Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Issue with 'Left' in macro

Hi - this is driving me crazy -- below is code to re-size an object and then
move it -- what seems to be happening is that the it is not being moved as
the code specifies. I have five other blocks of code for five other objects
-- the blocks of code are identical -- and the other five objects are being
moved as specified by the code. Any help is really appreciated!!

'After executing the below code, the object has a 'Left' position of 290 --
as the code specifies, it should be a different number than 290

Sub changepctg()

'M9 = 100
'M10 = 100
'F7 = 0.012
'AutoShape1 = a trapezoid from the "Autoshape" - "Flowchart" menu

Sheets("1st Level Graph (2)").Select

ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Height = Range("M9").Value
Selection.ShapeRange.Width = Range("M10").Value * (1 +
(Range("F7").Value - 0.5))
ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Top = ((Selection.ShapeRange.Top - 15) / 2) + 15
Selection.ShapeRange.Left = ((Selection.ShapeRange.Left - 290) / 2) + 290
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Issue with 'Left' in macro

What is the original .Left value for the ShapeRange for your AutoShape 1?
Note that if it was already 290, the result would be 290. But I will
continue to look at the code to see if I can find any other issues.
--
- K Dales


"Linking to specific cells in pivot table" wrote:

Hi - this is driving me crazy -- below is code to re-size an object and then
move it -- what seems to be happening is that the it is not being moved as
the code specifies. I have five other blocks of code for five other objects
-- the blocks of code are identical -- and the other five objects are being
moved as specified by the code. Any help is really appreciated!!

'After executing the below code, the object has a 'Left' position of 290 --
as the code specifies, it should be a different number than 290

Sub changepctg()

'M9 = 100
'M10 = 100
'F7 = 0.012
'AutoShape1 = a trapezoid from the "Autoshape" - "Flowchart" menu

Sheets("1st Level Graph (2)").Select

ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Height = Range("M9").Value
Selection.ShapeRange.Width = Range("M10").Value * (1 +
(Range("F7").Value - 0.5))
ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Top = ((Selection.ShapeRange.Top - 15) / 2) + 15
Selection.ShapeRange.Left = ((Selection.ShapeRange.Left - 290) / 2) + 290

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Issue with 'Left' in macro

I duplicated your code with the same type of autoshape (trapezoid from
Autoshape flowchart) with the following results for the .Left property of the
ShapeRange (original value : result value):
230.25 : 260.25
570.75 : 430.5
290:290

So unless the original .Left is 290 (or very close) the code seems to move
it. One question did come to mind: Is this shape part of a group of shapes?
The ShapeRange refers to the entire group, so if you have grouped the
trapezoid with any other shapes you are setting the left edge of the group,
not the left edge of your trapezoid. That might explain the results you are
getting.

--
- K Dales


"K Dales" wrote:

What is the original .Left value for the ShapeRange for your AutoShape 1?
Note that if it was already 290, the result would be 290. But I will
continue to look at the code to see if I can find any other issues.
--
- K Dales


"Linking to specific cells in pivot table" wrote:

Hi - this is driving me crazy -- below is code to re-size an object and then
move it -- what seems to be happening is that the it is not being moved as
the code specifies. I have five other blocks of code for five other objects
-- the blocks of code are identical -- and the other five objects are being
moved as specified by the code. Any help is really appreciated!!

'After executing the below code, the object has a 'Left' position of 290 --
as the code specifies, it should be a different number than 290

Sub changepctg()

'M9 = 100
'M10 = 100
'F7 = 0.012
'AutoShape1 = a trapezoid from the "Autoshape" - "Flowchart" menu

Sheets("1st Level Graph (2)").Select

ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Height = Range("M9").Value
Selection.ShapeRange.Width = Range("M10").Value * (1 +
(Range("F7").Value - 0.5))
ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Top = ((Selection.ShapeRange.Top - 15) / 2) + 15
Selection.ShapeRange.Left = ((Selection.ShapeRange.Left - 290) / 2) + 290

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Issue with 'Left' in macro

Hi K,

Thanks for looking into this! After looking reading your response, I looked
at my code closer and foud what the problem was -- the trapezoid was being
resized by shortening it from right to left -- the result being that the Left
position of the trapezoid was not changing (the other trapezoids I have in my
spreadsheet are oriented at different angles which leads to them not being
resized from right to left).

The fix is that I simply orient the trapezoid 180 degrees before being
resized (this results in the trapezoid being re-sized from left to right
which means the Left position changes). After the new Left position is set,
I just re-orient it to 0 degrees.

Thanks for your help!

Robert

"K Dales" wrote:

I duplicated your code with the same type of autoshape (trapezoid from
Autoshape flowchart) with the following results for the .Left property of the
ShapeRange (original value : result value):
230.25 : 260.25
570.75 : 430.5
290:290

So unless the original .Left is 290 (or very close) the code seems to move
it. One question did come to mind: Is this shape part of a group of shapes?
The ShapeRange refers to the entire group, so if you have grouped the
trapezoid with any other shapes you are setting the left edge of the group,
not the left edge of your trapezoid. That might explain the results you are
getting.

--
- K Dales


"K Dales" wrote:

What is the original .Left value for the ShapeRange for your AutoShape 1?
Note that if it was already 290, the result would be 290. But I will
continue to look at the code to see if I can find any other issues.
--
- K Dales


"Linking to specific cells in pivot table" wrote:

Hi - this is driving me crazy -- below is code to re-size an object and then
move it -- what seems to be happening is that the it is not being moved as
the code specifies. I have five other blocks of code for five other objects
-- the blocks of code are identical -- and the other five objects are being
moved as specified by the code. Any help is really appreciated!!

'After executing the below code, the object has a 'Left' position of 290 --
as the code specifies, it should be a different number than 290

Sub changepctg()

'M9 = 100
'M10 = 100
'F7 = 0.012
'AutoShape1 = a trapezoid from the "Autoshape" - "Flowchart" menu

Sheets("1st Level Graph (2)").Select

ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Height = Range("M9").Value
Selection.ShapeRange.Width = Range("M10").Value * (1 +
(Range("F7").Value - 0.5))
ActiveSheet.Shapes("AutoShape 1").Select
Selection.ShapeRange.Top = ((Selection.ShapeRange.Top - 15) / 2) + 15
Selection.ShapeRange.Left = ((Selection.ShapeRange.Left - 290) / 2) + 290

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
issue with "left" pierre Excel Discussion (Misc queries) 5 June 21st 09 05:14 PM
macro to sort right to left Steve Excel Discussion (Misc queries) 1 April 3rd 09 01:40 AM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM
Macros - stepping left in a macro Rich H. Excel Programming 2 October 5th 03 06:45 PM
LEFT Function in Macro Shauna Koppang Excel Programming 6 August 21st 03 02:21 AM


All times are GMT +1. The time now is 04:00 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"