From many scripts and apps that I have tested, this one is the only that works perfectly (and looks quite simple!)
tell application "Finder"
set input to selection
end tell
tell application id "com.microsoft.Word"
activate
set view type of view of active window to draft view
repeat with aFile in input
open aFile
set theOutputPath to ((aFile as text) & ".pdf")
repeat while not (active document is not missing value)
delay 0.5
end repeat
set activeDoc to active document
save as activeDoc file name theOutputPath file format format PDF
close active document saving no
end repeat
end tell
Tested with MS Word for Mac 16.44 on macOS Catalina.
Together with the KM macro to merge a folder with PDF files to one PDF, this is pure gold.
I’ve recently duplicated and modified the script to convert the older .doc to the newer .docx format that my CAT tool can process: worked like a charm too.
tell application "Finder"
set input to selection
end tell
tell application id "com.microsoft.Word"
activate
set view type of view of active window to draft view
repeat with aFile in input
open aFile
set theOutputPath to ((aFile as text) & ".docx")
repeat while not (active document is not missing value)
delay 0.5
end repeat
set activeDoc to active document
save as activeDoc file name theOutputPath file format format document
close active document saving no
end repeat
end tell
Thanks for posting this code, it gets me a part way to solving my problem.
I’m at the start of a huge learning curve with Applescript and feel way out of my depth. I’m sure what I’m trying to achieve is possible but I don’t know how to go about it.
I am trying to create a Droplet that will convert Word documents into pdf files and save them into a designated folder, not the same folder as the Word documents. Seems straightforward enough.
Google showed me your script that will save pdfs into the same folder as the Word documents but that’s not what I require and I don’t know how to change it.
Another problem is the script only works with straight forward Word documents. By that I mean the files I’m working with all have multiple links to external data in an Excel workbook. The links are set to automatically update. When the document opens, a prompt appears requiring a response. I don’t know how to write a script that answers the prompt. See image.
All the files open but the script fails at the prompt, so I have to manually click ‘Yes’ for each one.
Ideally the script would answer ‘Yes’ (not ‘No’) to the prompt for each file in the list and then save a pdf into my designated folder before closing.
Another problem. The automatic update setting, triggers another prompt on closing the document, asking if I want to save changes or not; ideally yes. I don’t know how to write a script to answer this prompt either.
Turning the ‘Update: automatically’ option on and off gets around the prompts but it’s not really a viable solution. In short, I'm looking for a Droplet that can answer both prompts appropriately and also save a pdf to my designated folder.
Before I post a new thread, I thought I'd ask here first . . .
Here's what I'm looking to do: I drop a Word document into a folder and that document is then automatically/instantly converted to PDF. Does this script get me there? I am admittedly very much a novice at this, but the script looks like it at least handles the conversion part of the process.
Note that this macro works with .docx format Word documents only; Word needs to be running for this to work smoothly or at all; you must enter the file path of the destination folder at the top of the macro so that KM will monitor the folder:
The first time you use the macro, Word may ask for you to grant access to the folder, after which it should not ask for access on further runs.
(The folder watcher excludes files with filenames that include "~$" - this accounts for partial PDF file which appears briefly in the folder during conversion.)