View Full Version : Determine ScaleHeight of an image
stranno
02-26-2017, 07:13 AM
Hi,
Is it possible to determine the ScaleHeight of an selected Image?
I know that setting the ScaleHeight is a method and not a property, But I need to know the current ScaleHeight.
MsgBox ActiveSheet.Shapes.Range(Array("Image1")).ScaleHeight for instance does not work.
stranno
jolivanes
02-26-2017, 12:57 PM
Found the needed code here.
http://stackoverflow.com/questions/28212898/determine-actual-and-displayed-size-of-picture-object-in-vba
Sub Main()
'Thanks to Marek Stejskal
Dim myShape As Excel.Shape
Dim measurements() As Single
Dim Original_Width As Double
Dim Original_Height As Double
Dim Current_Width As Double
Dim Current_Height As Double
Set myShape = ActiveWorkbook.ActiveSheet.Shapes(1)
measurements = GetOriginalMeasurements(myShape)
Current_Width = myShape.width
Current_Height = myShape.height
Original_Width = measurements(0)
Original_Height = measurements(1)
MsgBox "ScaleWidth: " & Current_Width / (Original_Width / 100)
MsgBox "ScaleHeight: " & Current_Height / (Original_Height / 100)
End Sub
Private Function GetOriginalMeasurements(ByRef myShape As Excel.Shape)
Dim shpCopy As Excel.Shape
Dim measurements(1) As Single
Set shpCopy = myShape.Duplicate
' Reset original measurements
shpCopy.ScaleHeight 1, msoTrue
measurements(0) = shpCopy.width
measurements(1) = shpCopy.height
shpCopy.Delete
GetOriginalMeasurements = measurements
End Function
Hopelijk is dit wat je voor ogen had.
Hope that this is what you had in mind.
Good luck
stranno
02-27-2017, 12:28 AM
Works perfect. Thanks Jolivanes.
Geemigreerd naar Canada?
jolivanes
02-27-2017, 08:46 AM
Ja, 47 jaar geleden.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.