2012-09-29 12 views
1

我在我的Macbook上使用MS Powerpoint 2008。我使用提供的Automator动作将一堆图像(大约100个)添加到新的PPTX文件中。图像居中,但它们并未完全最大化。可以使用的边缘周围有大约0.5-1英寸的空间。我更喜欢将图像垂直或水平最大化,或者选择适合图像的图像。使用AppleScript在Powerpoint中最大化调整图像

任何想法如何添加代码,以确定图像(形状)最好是最大化到幻灯片高度(7.5 x 72像素/英寸)或宽度(10英寸或720像素)?

这是到目前为止我的代码:

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 

这里是实施建议后,我更新的代码。我不得不增加一行,以检查在图像比高大更宽箱子尺寸调整后的高度不超过所述滑动高度,但是不是在滑动相同的比例7.5×10:

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 

回答

1

首先,为什么“将形状的高度设置为(7.5 * 70)”?

默认滑块高度是7.5 * 72(7.5英寸x每英寸72点)

假设图像已经添加到幻灯片,你会想看看图像的宽度除以高度。如果结果为1或更小,则图像是正方形或高于宽度,因此您需要垂直居中。如果它> 1,则将其居中放置。

+0

感谢您的帮助。 70是一个错字。我应该按照你的建议使用72。 – dskrad