Note that there are some explanatory texts on larger screens.

plurals
  1. POMaximize Resize Images in Powerpoint using Applescript
    text
    copied!<p>I am using MS Powerpoint 2008 on my macbook. I have used the provided Automator action to add a bunch of images (100 or so) into a new PPTX file. The images are centered, but they are not completely maximized. There is about 0.5-1 inch of space around the edges that could be used. I prefer the images to be maximized either vertically or horizontally, or whichever is appropriate for the image. </p> <p>Any idea how to add code that would determine if the image (shape) would better be maximized to the slide height (7.5 in x 72 px/in) or width (10 in or 720 px)?</p> <p>Here is my code so far:</p> <pre><code>tell application "Microsoft PowerPoint" activate set thePres to active presentation set slideCount to count slides of thePres repeat with a from 1 to slideCount set theShape to first shape of slide a of thePres set height of theShape to (7.5 * 70) set leftPos to (slide width of page setup of thePres) - (width of theShape) set left position of theShape to (leftPos / 2) set top of theShape to 0 end repeat end tell </code></pre> <p>Here is my updated code after implementing suggestion. I had to add a line to check that the height did not exceed the slide height after resizing in cases where the image was wider than tall, but was not the same ratio as 7.5 x 10 in slide:</p> <pre><code>tell application "Microsoft PowerPoint" activate set thePres to active presentation set slideCount to count slides of thePres repeat with a from 1 to slideCount set theShape to first shape of slide a of thePres if height of theShape is greater than width of theShape then set height of theShape to (7.5 * 72) else set width of theShape to (10 * 72) end if if height of theShape is greater than 540 then set height of theShape to 540 end if set leftPos to (slide width of page setup of thePres) - (width of theShape) set left position of theShape to (leftPos / 2) set top of theShape to 0 end repeat end tell </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload