AppleScript – Word DOC(X) Document to PDF - Permission Problem


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!

1 Like

Hey @Atompersona,

Welcome to the forum!  :sunglasses:

  • 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?

Take Care,

(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: which pandoc)

1 Like

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.

Screen Shot 2023-03-13 at 08.03.09

Screen Shot 2023-03-13 at 08.03.23

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:

Sub SaveActiveDocumentAsPdf()

    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
    End If

    On Error GoTo 0

    Exit Sub


    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

End Sub

You just open this macro in the VBA editor and you click the run triangle :arrow_forward: until no document is open anymore :slight_smile: .

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...