a VBA question - capture scale of a graphic?

G

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.
 
S

SongBear

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
 
S

SongBear

Scaleheight?...ScaleWidth?...stupid Bear learn something new every day...

Steve Rindsberg said:
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
================================================
 
G

Gregg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top