我在我的 macbook 上使用 MS Powerpoint 2008。我已经使用提供的 Automator 操作将一堆图像(大约 100 个)添加到一个新的 PPTX 文件中。图像居中,但并未完全最大化。边缘周围大约有 0.5-1 英寸的空间可供使用。我更喜欢垂直或水平最大化图像,或者以适合图像的方式最大化。
知道如何添加代码来确定图像(形状)是否会更好地最大化到幻灯片高度(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 x 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