I have a small AppleScript to save a PowerPoint pptx file as PDF from command line. I use the script every 6 months, and last autumn it still worked. But today I run into problems. I updated to 10.14 in the meantime, and I guess there were also quite some Office for Mac updates. But as I have no clue about where this problem is coming from, these can also be completely irrelevant information.

The problem with the script is: When calling the script, it doesn't save a PDF, but sends the file to the default printer.

Here is the already updated, but still not working script:

on run arguments
    tell application "Finder"
        set src to POSIX file (first item of arguments) as alias
        set dest to (second item of arguments) as text

        open src
        delay 10

        tell application "Microsoft PowerPoint"
            save in dest as save as PDF
        end tell
    end tell
end run

As there is not much code, and as the script did work before, I have no idea on what is wrong with it now.

@MaxWyss's comment brought me to look at the script from command line. I executed the few steps as arguments via osascript:

$ osascript -e 'tell application "Finder"' -e 'set fileAlias to POSIX file ("file:///Users/me/folder/file.pptx") as alias' -e 'set theOutputPath to ("file:///Users/me/folder/test.pdf") as text' -e 'open fileAlias' -e 'delay 10' -e 'tell application "Microsoft PowerPoint"' -e 'save in theOutputPath as save as PDF' -e 'end tell' -e 'end tell'
281:320: execution error: Microsoft PowerPoint got an error: Parameter error. (-50)

I'm a little surprised about the error message, so I tried to run the script again:

$ osascript pptx2pdf.scpt file:///Users/me/folder/file.pptx test.pdf
pptx2pdf.scpt: execution error: Microsoft PowerPoint got an error: Parameter error. (-50)

I don't know why I overlooked this error. I guess it is due to the many things I changed in the script. However, this is the error message, which, unfortunately, still leaves me without a clue, as the slides still get sent to the printer queue.

  • What happens if you do the steps manually, without the script? – Max Wyss Feb 1 at 10:19
  • @MaxWyss What do you mean by "manually"? "Save as" as well as "Export" in Powerpoint work as expected. Or do you mean to execute the script instructions on some kind of terminal? If the latter, how can I do this? – PVitt Feb 1 at 12:29
  • Actually, with "manually", I meant to do what you want to do with the script using the programm's user interfaces. However, your update to the message gave me another idea… Especially, if you are doing rather serious Applescripting, investing in Script Debugger by Late Night Software would be worth every penny… That would definitely help you locate the issue. It would also give you the possibility to look at PowerPoint's Applescript dictionary, helping with the parameters. – Max Wyss Feb 1 at 17:51
  • @MaxWyss Thanks for your advice, however, the dictionary doesn't really help. It says save [in file], but I'm not able to make the second argument a file or POSIX file. This is really annoying. I guess, I have to explort them by hand... – PVitt Feb 2 at 19:37

You must log in to answer this question.

Browse other questions tagged .