Scaleheight of image

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
Trying to get and set an image's scaleheight and width

Code:
msgbox activesheet.Shapes(1).ScaleHeight

returns nothing. I realize there are 3 parts to Scaleheight and width

Help a brother out? Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
ScaleHeight is a method not a property & needs the first 2 arguments
ScaleHeight( Factor , RelativeToOriginalSize , Scale )
 
Upvote 0
How do I get the stored arguments of an existing image so that I can set another image to match it?
 
Last edited:
Upvote 0
I've no idea, assuming it's even possible.
Couldn't you just get the height & width & use that?
 
Upvote 0
Maybe
Code:
Dim SHValue As Single
SHValue = ActiveSheet.Shapes(1).Height
ActiveSheet.Shapes(1).ScaleHeight 1, msoTrue
SHValue = SHValue / ActiveSheet.Shapes(1).Height
ActiveSheet.Shapes(1).ScaleHeight SHValue, msoTrue
 
Last edited:
Upvote 0
Maybe
Code:
Dim SHValue As Single
SHValue = ActiveSheet.Shapes(1).Height
ActiveSheet.Shapes(1).ScaleHeight 1, msoTrue
SHValue = SHValue / ActiveSheet.Shapes(1).Height
ActiveSheet.Shapes(1).ScaleHeight SHValue, msoTrue

height and scaleheight's SHValue as you dim it here are not the same. height is typically in pixels and scaleheight is a percentage. I'm beginning to think it can't be done :)
 
Upvote 0
height and scaleheight's SHValue as you dim it here are not the same...
From the MS help:

Shape.Height Property (Excel) -- Returns or sets a Single value that represents the height, in points, of the object.
Shape.ScaleHeight Method (Excel) -- Syntax: expression.ScaleHeight(Factor,RelativeToOriginalSize,Scale); Factor: Data Type Single.
 
Upvote 0
From the MS help:

Shape.Height Property (Excel) -- Returns or sets a Single value that represents the height, in points, of the object.
Shape.ScaleHeight Method (Excel) -- Syntax: expression.ScaleHeight(Factor,RelativeToOriginalSize,Scale); Factor: Data Type Single.


Hmmm... and I tested your code. Seems to work on a test, now testing on my real project....
 
Upvote 0

Forum statistics

Threads
1,215,202
Messages
6,123,625
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top