A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Powerpoint
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

a VBA question - capture scale of a graphic?



 
 
Thread Tools Display Modes
  #1  
Old May 13th, 2005, 05:00 PM
Gregg
external usenet poster
 
Posts: n/a
Default a VBA question - capture scale of a graphic?

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.

  #2  
Old May 13th, 2005, 08:28 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article . com, Gregg wrote:
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
================================================


  #3  
Old May 13th, 2005, 08:28 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article . com, Gregg wrote:
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
================================================


  #4  
Old May 13th, 2005, 09:14 PM
SongBear
external usenet poster
 
Posts: n/a
Default

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, we

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

"Gregg" wrote:

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.


  #5  
Old May 13th, 2005, 09:30 PM
SongBear
external usenet poster
 
Posts: n/a
Default

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

"Steve Rindsberg" wrote:

In article . com, Gregg wrote:
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
================================================



  #6  
Old May 13th, 2005, 09:52 PM
Gregg
external usenet poster
 
Posts: n/a
Default

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.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which chart will do what I want? I Clarified My Question... Ginger Charts and Charting 1 March 27th, 2004 03:18 PM
Unusual Y Axis Scale Question Gene Charts and Charting 6 February 10th, 2004 02:18 AM
Charting in a single cell question... LSMark Charts and Charting 3 January 8th, 2004 04:00 PM


All times are GMT +1. The time now is 02:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.