Bonky Zhu
If someone is able to show me that what I think or do is not right, I will happily change, for I seek the truth, by which no one was ever truly harmed. It is the person who continues in his self-deception and ignorance who is harmed.

macOS 利用 automator 将 PPT 批量专为 PDF

转自:https://blog.csdn.net/qianzuishi7059/article/details/78065598

和博主一样的原因,我也是想要需要将 PPT 转为 PDF 在 ipad 上记笔记,但不过还有个原因,就是 PowerPoint 实在太卡啦,打开都要等半天。下面是批量转换的步骤:

  1. 新建 automator 工作流程
  2. 将待转换文件拖入到操作框中
  3. 添加运行AppleScript到操作框
  4. 将下列代码复制到 AppleScript 中
on run {input, parameters}
    set theOutput to {}
    tell application "Microsoft PowerPoint" -- work on version 15.15 or newer
        launch
        set theDial to start up dialog
        set start up dialog to false
        repeat with i in input
            open i
            set pdfPath to my makeNewPath(i)
            save active presentation in pdfPath as save as PDF -- save in same folder
            close active presentation saving no
            set end of theOutput to pdfPath as alias
        end repeat
        set start up dialog to theDial
    end tell
    return theOutput
end run

on makeNewPath(f)
    set t to f as string
    if t ends with ".pptx" then
        return (text 1 thru -5 of t) & "pdf"
    else
        return t & ".pdf"
    end if
end makeNewPath

  1. 点击运行即可

屏幕快照 2019-11-13 下午9.01.26

2019.12.2 新增
下面的这个代码可以自动识别 ppt,docx,doc 然后转换为 pdf

on run {input, parameters}
    set ppt to {}
    set doc to {}
    set theOutput to {}
    repeat with i in input
        set aname to i as string
        if aname ends with ".pptx" then
            set the end of ppt to i
        else
            set the end of doc to i
        end if
    end repeat
  runppt(ppt)
  runword(doc)
    return theOutput
end run

on runppt(input)
    set theOutput to {}
    tell application "Microsoft PowerPoint" -- work on version 15.15 or newer
        launch
        set theDial to start up dialog
        set start up dialog to false
        repeat with i in input
            open i
            set pdfPath to my makeNewPPTPath(i)
            save active presentation in pdfPath as save as PDF -- save in same folder
            close active presentation saving no
            set end of theOutput to pdfPath as alias
        end repeat
        set start up dialog to theDial
    end tell
    return theOutput
end runppt

on makeNewPPTPath(f)
    set t to f as string
    if t ends with ".pptx" then
        return (text 1 thru -5 of t) & "pdf"
    else
        return t & ".pdf"
    end if
end makeNewPPTPath

on runword(input)
    set theOutput to {}
    tell application "Microsoft Word"
        repeat with thefile in input
            open thefile
            set pdfPath to my makeNewWordPath(thefile)
            set theActiveDoc to the active document
            save as theActiveDoc file format format PDF file name pdfPath
            close theActiveDoc saving no
        end repeat
    end tell
    return theOutput
end runword

on makeNewWordPath(f)
    set d to f as string
    if d ends with ".docx" then
        return (text 1 thru -5 of d) & "pdf"
    else if d ends with ".doc" then
        return (text 1 thru -4 of d) & "pdf"
    else
        return d & ".pdf"
    end if
end makeNewWordPath

Share

You may also like...

发表评论