Discussion:
a VBA question - capture scale of a graphic?
(too old to reply)
Gregg
2005-05-13 16:00:05 UTC
Permalink
In VBA, how do I capture the scale% of a selected graphic?

I'm trying...
iOrgScale = ActiveWindow.Selection.ShapeRange.ScaleHeight

But that obviously doesn't work.

Thanks.
Steve Rindsberg
2005-05-13 19:28:10 UTC
Permalink
Post by Gregg
In VBA, how do I capture the scale% of a selected graphic?
You'd want to store its current height and width
Then

With [the shape that represents the graphic]
' Reset it to original size on import:
.ScaleWidth 1, True
.ScaleHeight 1, True
End with

Then do the math by comparing the original and the reset dimensions and finally
set it back to the original size

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
SongBear
2005-05-13 20:30:14 UTC
Permalink
Scaleheight?...ScaleWidth?...stupid Bear learn something new every day...
Post by Steve Rindsberg
Post by Gregg
In VBA, how do I capture the scale% of a selected graphic?
You'd want to store its current height and width
Then
With [the shape that represents the graphic]
.ScaleWidth 1, True
.ScaleHeight 1, True
End with
Then do the math by comparing the original and the reset dimensions and finally
set it back to the original size
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Gregg
2005-05-13 20:52:04 UTC
Permalink
How funny. Until I could get an answer I 'rigged' a way to do it, which
turns out to be the same method you wrote. That worked out well.

Thanks, Steve.

Steve Rindsberg
2005-05-13 19:28:09 UTC
Permalink
Post by Gregg
In VBA, how do I capture the scale% of a selected graphic?
I'm trying...
iOrgScale = ActiveWindow.Selection.ShapeRange.ScaleHeight
But that obviously doesn't work.
Thanks.
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
SongBear
2005-05-13 20:14:03 UTC
Permalink
Greg
Can I assume you mean aspect ratio? I can help you with that.
Aspect ratio (Google it for a better explaination, I am going to reference
only one of the several sites I “consulted” to wit:
http://www.doom9.org/index.html?/aspectratios.htm
The old NTSC value for the standard TV that we grew up with is 4:3 width to
height. This is equal to 1.33:1 (1.33 to 1). It is also generally equal to
the VGA resolution 640:480 (really 638.4:480, but who’s counting).
If you have some code that selects the shape, you can use the .Height and
.Width properties to get the aspect ratio.

My code assigned .Height to hyt and .Width to wdt (variants)

AFTER a shape is selected by your code:

With ActiveWindow.Selection.ShapeRange
hyt = .Height
wdt = .Width
Debug.Print "Height = " & hyt & " and Width = " & wdt & ". So the Aspect
Ratio is = " & wdt / hyt & ":1."
End With

(Note the debug.print code wraps in this window.)

Some of the output, copied from the Immediate pane, were:

Height = 427.5 and Width = 750. So the Aspect Ratio is = 1.754386:1.
Height = 750 and Width = 750. So the Aspect Ratio is = 1:1.
Height = 392.25 and Width = 600. So the Aspect Ratio is = 1.529637:1.
Height = 562.5 and Width = 450. So the Aspect Ratio is = 0.8:1.
Height = 768 and Width = 960. So the Aspect Ratio is = 1.25:1.
Height = 720 and Width = 960. So the Aspect Ratio is = 1.333333:1.
Height = 483.75 and Width = 450. So the Aspect Ratio is = 0.9302326:1.
Height = 768 and Width = 960. So the Aspect Ratio is = 1.25:1.
Height = 750 and Width = 750. So the Aspect Ratio is = 1:1.
Height = 738 and Width = 750. So the Aspect Ratio is = 1.01626:1.
Height = 778.5 and Width = 750. So the Aspect Ratio is = 0.9633911:1.
Height = 562.5 and Width = 750. So the Aspect Ratio is = 1.333333:1.
Height = 750 and Width = 750. So the Aspect Ratio is = 1:1.
Height = 698.25 and Width = 960. So the Aspect Ratio is = 1.374866:1.
Height = 325.5 and Width = 262.5. So the Aspect Ratio is = 0.8064516:1.
Height = 900 and Width = 1200. So the Aspect Ratio is = 1.333333:1.
Height = 750 and Width = 600. So the Aspect Ratio is = 0.8:1.
Height = 600 and Width = 750. So the Aspect Ratio is = 1.25:1.
Height = 768 and Width = 960. So the Aspect Ratio is = 1.25:1.

Note: This does start with a completed personal code project of mine in
PowerPoint VBA that automatically resizes and inserts pictures from files
into slides, but with the subject of aspect ratio, I am looking up stuff and
winging it here. If anybody knows something better, please chime in.
Hope this helps.
SongBear
Post by Gregg
In VBA, how do I capture the scale% of a selected graphic?
I'm trying...
iOrgScale = ActiveWindow.Selection.ShapeRange.ScaleHeight
But that obviously doesn't work.
Thanks.
Loading...