2012-09-29 31 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