如何自动化主题工作流程以将幻灯片展平为图像幻灯片以导出到.ppt

问题描述 投票:0回答:1

我总是在主题演讲中设计我的演示幻灯片(因为我觉得它更容易和更愉快地工作),虽然它们经常需要在运行PowerPoint的Windows机器上呈现。

为了避免字体,格式等问题,我总是使用以下有效工作流程:

  1. 在主题演讲中设计幻灯片,通常使用图像和文本。
  2. 将幻灯片导出为jpg文件到桌面上的文件夹。
  3. 打开一个新的主题演讲。
  4. 将jpg文件拖到幻灯片导航器中。这将创建每个jpg的图像幻灯片。
  5. 将新演示文稿导出到.ppt文件。

有没有办法让这个工作流程自动化?我希望将第2-5步折叠成一步!

applescript automator
1个回答
4
投票

这是执行此操作的AppleScript(适用于Keynote 6.2版,而不适用于版本5):

tell application "Finder" to set f to (make new folder) as text -- create a temp folder to export images
tell application "Keynote"
    tell front document
        export to (file f) as slide images with properties {image format:JPEG, compression factor:95}
        set {h, w, fPath} to {height, width, file of it}
    end tell
    tell (fPath as string) to if it ends with ".key:" then
        set newFile to (text 1 thru -6) & ".ppt"
    else
        set newFile to it & ".ppt"
    end if
    set jpegs to my getImages(f)
    set newDoc to make new document with properties {width:w, height:h}
    tell newDoc
        set mSlide to last master slide -- blank
        repeat with thisJPEG in jpegs
            set s to make new slide with properties {base slide:mSlide}
            tell s to make new image with properties {file:thisJPEG}
        end repeat
        delete slide 1
        export to (file newFile) as Microsoft PowerPoint
        close saving no
    end tell
end tell
tell application "Finder" to delete folder f -- delete the temp folder
on getImages(f)
    tell application "Finder" to return (files of folder f) as alias list
end getImages

重要提示:在运行脚本之前,幻灯片必须已在Keynote中打开。

并且必须已保存幻灯片,因为脚本使用前端文档的路径将PPT文件保存在同一文件夹中。

--

更新:选择新文件的位置

set v to ("Volumes" as POSIX file) as alias
tell application "Finder" to set f to (make new folder) as text -- create a temp folder to export images
tell application "Keynote"
    tell front document
        export to (file f) as slide images with properties {image format:JPEG, compression factor:95}
        set {h, w, tName} to {height, width, name of it}
    end tell
    tell tName to if it ends with ".key" then
        set newName to (text 1 thru -5) & ".ppt"
    else
        set newName to it & ".ppt"
    end if
    set jpegs to my getImages(f)
    activate
    set newFile to choose file name default name newName default location v with prompt "Select the folder to save the PPT file"
    set newDoc to make new document with properties {width:w, height:h}
    tell newDoc
        set mSlide to last master slide -- blank
        repeat with thisJPEG in jpegs
            set s to make new slide with properties {base slide:mSlide}
            tell s to make new image with properties {file:thisJPEG}
        end repeat
        delete slide 1
        export to (newFile) as Microsoft PowerPoint
        close saving no
    end tell
end tell
tell application "Finder" to delete folder f -- delete the temp folder

on getImages(f)
    tell application "Finder" to return (files of folder f) as alias list
end getImages
© www.soinside.com 2019 - 2024. All rights reserved.