Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how to batch convert Word files to pdf

How do I batch convert Word files to pdf using Automator

MacBook Pro, OS X Yosemite (10.10.2)

Posted on Mar 18, 2015 12:56 PM

Reply
31 replies

Mar 21, 2015 9:06 AM in response to 32Mine

I guess you have to use applescript:

instead of convert to pdf action, add "Run Applescript"

property theList : {"doc", "docx"}


on run {input, parameters}

set output to {}

tell application "Microsoft Word" to set theOldDefaultPath to get default file pathfile path typedocuments path

repeat with x in input

try

set theDoc to contents of x

tell application "Finder"

set theFilePath to container of theDoc as text


set ext to name extension of theDoc

if ext is in theList then

set theName to name of theDoc

copy length of theName to l

copy length of ext to exl


set n to l - exl - 1

copy characters 1 through n of theName as string to theFilename


set theFilename to theFilename & ".pdf"


tell application "Microsoft Word"


set default file pathfile path typedocuments pathpaththeFilePath

open theDoc

set theActiveDoc to the active document


save astheActiveDocfile formatformat PDFfile nametheFilename

copy (POSIX path of (theFilePath & theFilename as string)) to end of output


closetheActiveDoc

end tell

end if

end tell

end try

end repeat

tell application "Microsoft Word" to set default file pathfile path typedocuments pathpaththeOldDefaultPath



return output

end run

Paste this script in the run applescript box.

Mar 21, 2015 9:21 AM in response to 32Mine

Try again.

property theList : {"doc", "docx"}


on run {input, parameters}

set output to {}

tell application "Microsoft Word" to set theOldDefaultPath to get default file pathfile path typedocuments path

repeat with x in input

try

set theDoc to contents of x

tell application "Finder"

set theFilePath to container of theDoc as text


set ext to name extension of theDoc

if ext is in theList then

set theName to name of theDoc

copy length of theName to l

copy length of ext to exl


set n to l - exl - 1

copy characters 1 through n of theName as string to theFilename


set theFilename to theFilename & ".pdf"


tell application "Microsoft Word"


set default file pathfile path typedocuments pathpaththeFilePath

open theDoc

set theActiveDoc to the active document


save astheActiveDocfile formatformat PDFfile nametheFilename

copy (POSIX path of (theFilePath & theFilename as string)) to end of output


closetheActiveDoc

end tell

end if

end tell

end try

end repeat

tell application "Microsoft Word" to set default file pathfile path typedocuments pathpaththeOldDefaultPath



return output

end run

how to batch convert Word files to pdf

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.