2020-09-08

wold 批量转PDF

--AppleScript.Word_to_Pdf[By.龙律师一本正经的代码]

on run {input, parameters} 

    set theOutput to {} 

    tell application "Microsoft Word"       

        repeat with thefile in input           

            open thefile           

            set pdfPath to my makeNewPath(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 run

on makeNewPath(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 makeNewPath

--Time.20180302

--代码链接https://zhuanlan.zhihu.com/p/34204905

你可能感兴趣的:(2020-09-08)