I shamelessly stole the script from the following thread (AppleScript – Save Microsoft Word DOC(X) Document to PDF) to batch convert Word files to PDF.
Unfortunately, I have the problem that for each file, two dialogs always come up where I have to grant Word additional permissions for the file. I have already given Word full disk access, but unfortunately it still doesn't work. Could someone help me here? I am a total beginner unfortunately.
Thank you very much!
Welcome to the forum!
- What version of macOS?
- What version of Keyboard Maestro?
- What version of Word (MS Office what?)
- What's the path you're trying to save to?
If you haven't read this it's worth a couple of minutes of your time.
Tip: How Do I Get The Best Answer in the Shortest Time?
(Keyboard Maestro Moderator)
FWIW this is something for which I would personally use the free (and excellent) utility:
Pandoc - a universal document converter
- calling it from a Keyboard Maestro Execute a shell script action,
- and supplying the full path to the installation location of the pandoc executable.
[fullpath]/pandoc -f docx -t pdf sample.docx -o sample.pdf
(once you have installed pandoc, you can find the full path to it with the command line incantation:
I have the same problem with this macro that merges all subdocuments in a folder to one "Master" document. I have granted Ms Word full disk access. Nevertheless I have to grant each and every subdocument access. I consider this a bug in Ms Word. In a different context, some drastic solutions have been suggested. I will try these on my test Mac.
Hey @Atompersona, when everything fails, you can use this simple macro. First you open all docx files to convert. Then you run this macro on every document:
On Error GoTo Errhandler
If InStrRev(ActiveDocument.FullName, ".") <> 0 Then
Dim strPath As String
strPath = Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, ".") - 1) & ".pdf"
ActiveDocument.SaveAs2 FileName:=strPath, FileFormat:=wdFormatPDF
On Error GoTo 0
MsgBox "There was an error saving a copy of this document as Pdf. " & _
"Ensure that the Pdf is not open for viewing and that the destination path is writable. Error code: " & Err
You just open this macro in the VBA editor and you click the run triangle until no document is open anymore .
I received an email from Ron de Bruin about how to fix/avoid the issue. He pointed me to this page on his website. It contains two links to pages with useful info.
The good thing about automation of Word for Mac is that you can also control Word via AppleScript (there is a thick manual about this topic!).
The bad thing is how Microsoft worked their way around Apple's sandboxing. Ron de Bruin wrote about the many steps you have to take to use Excel for Mac without problems with permissions.
I will have to investigate whether these steps apply to Word for Mac too...