Image 使用Applescript最大限度地调整Powerpoint中图像的大小
我正在macbook上使用MS Powerpoint 2008。我已经使用提供的Automator操作将一组图像(大约100个)添加到新的PPTX文件中。图像居中,但未完全最大化。边缘周围大约有0.5-1英寸的空间可供使用。我更喜欢垂直或水平最大化图像,或者选择适合图像的 您知道如何添加代码来确定图像(形状)是否最好最大化为幻灯片高度(7.5英寸x 72像素/英寸)或宽度(10英寸或720像素) 以下是我目前的代码:Image 使用Applescript最大限度地调整Powerpoint中图像的大小,image,resize,applescript,powerpoint,Image,Resize,Applescript,Powerpoint,我正在macbook上使用MS Powerpoint 2008。我已经使用提供的Automator操作将一组图像(大约100个)添加到新的PPTX文件中。图像居中,但未完全最大化。边缘周围大约有0.5-1英寸的空间可供使用。我更喜欢垂直或水平最大化图像,或者选择适合图像的 您知道如何添加代码来确定图像(形状)是否最好最大化为幻灯片高度(7.5英寸x 72像素/英寸)或宽度(10英寸或720像素) 以下是我目前的代码: tell application "Microsoft PowerPoint"
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
首先,为什么“将形状的高度设置为(7.5*70)”呢
默认幻灯片高度为7.5*72(7.5英寸*72点/英寸)
假设图像已经添加到幻灯片中,您希望查看图像的宽度除以高度。如果结果为1或更小,则图像为正方形或比宽高,因此您希望将其垂直居中。如果大于1,则将其水平居中。首先,为什么“将形状的高度设置为(7.5*70)”呢
默认幻灯片高度为7.5*72(7.5英寸*72点/英寸)
假设图像已经添加到幻灯片中,您希望查看图像的宽度除以高度。如果结果为1或更小,则图像为正方形或比宽高,因此您希望将其垂直居中。如果大于1,则将其水平居中。谢谢您的帮助。70是个打字错误。我应该按照你的建议使用72。谢谢你的帮助。70是个打字错误。我应该按照你的建议使用72。