新建自动操作如下:
其中
myslide
位于~/资源库/Group Containers/UBF8T346G9.Office/
之下,需要自己新建。这样不需设置文件访问权限。最后这里的mac script如下:
(*from https://it4np.com/2017/10/create-powerpoint-presentation-from-photos-videos-auto-layout-photos-videos-in-an-existing-presentat.html *)
property pictureExtensions : {"ai", "bmp", "eps", "gif", "jpg", "jpeg", "pct", "pdf", "pict", "png", "psd", "tif", "tiff"}
property movieExtensions : {"avi", "mp4", "mov"}
on run {input, parameters}
processFolderFiles(input)
return input
end run
on processFolderFiles(theFolderFiles)
set firstTime to true
tell application "System Events"
set theFileList to theFolderFiles
if (count of theFileList) is 0 then
display dialog "No pictures or movies found in the dropped files." buttons {"OK"} giving up after 10
return
end if
repeat with theCurrentItem in theFileList
set mediaType to ""
set thePath to path of theCurrentItem as string
set theExtension to name extension of theCurrentItem
if pictureExtensions contains theExtension then
set mediaType to "picture"
else if movieExtensions contains theExtension then
set mediaType to "movie"
end if
if mediaType ≠ "" then
if firstTime then
tell application "Microsoft PowerPoint"
set thePresentation to make new presentation
set firstTime to false
end tell
end if
tell me to createSlideFromMediaFile(thePath, mediaType)
end if
end repeat
if firstTime then
display dialog "No pictures or movies found in the dropped files." buttons {"OK"} giving up after 10
end if
end tell
end processFolderFiles
on createSlideFromMediaFile(theMediaFile, mediaType)
tell application "Microsoft PowerPoint"
tell active presentation
set theSlide to make new slide at end with properties {layout:slide layout blank}
tell theSlide
set follow master background to false
set fore color of fill format of background to {0, 0, 0}
set slideHeight to height of slide master
set slideWidth to width of slide master
set slideAspectRatio to slideWidth / slideHeight
if mediaType = "picture" then
set theMedia to make new picture at end with properties {file name:theMediaFile, lock aspect ratio:true, top:0, height:slideHeight}
else if mediaType = "movie" then
set theMedia to make new media2 object at end with properties ¬
{file name:theMediaFile, lock aspect ratio:true, top:0, height:slideHeight}
tell application "Microsoft PowerPoint" to set animate of animation settings of theMedia to true
end if
tell theMedia
scale height factor 1 scale scale from top left with relative to original size
set pictureAspectRatio to width / height
if pictureAspectRatio > slideAspectRatio then
-- taller than wide
set height to slideHeight
set top to 0
set left position to (slideWidth - width) / 2
else
-- wider than tall
set width to slideWidth
set top to (slideHeight - height) / 2
set left position to 0
end if
end tell
end tell
end tell
end tell
end createSlideFromMediaFile