Print to PDF file name 'untitled' since Ventura upgrade

How do I copy a filename without its extension and have it inserted into a pop up file dialogue box?

Here's the background. For the past 10 years I have used a shortcut CMD + P,P to quickly print to PDF. Almost 100% of its use is whilst using MS Word. Since upgrading to Ventura when I print to PDF, the filename which has always defaulted to the file name of whichever document I'm PDF'ing, now appears as 'untitled.pdf'

I have been unable to fix this, find any help from MS, or any other easy workaround. Yes I know I can manually retype the filename in, but it is a manual step that hasn't been needed for as long as I have been PDF'ing files and adds up to a fair bit of time each day.

So now I'm thinking a few KM additions can copy the filename of the active document in Word and replace the 'untitled.pdf' with 'filename.pdf' in the Save As... pop up dialogue box.

But... the only copy filename action I can locate in KM asks for the actual file location of which isn't possible until I create the file. Either that or it would require navigating to that folder and selecting the current file which probably is slower than typing in the filename manually.


Any pointers would be appreciated.

Hey Russell,

There is no such action – however there are methods of doing this.


Get Name … AppleScript[1]
tell application ((path to frontmost application) as text) to set frontAppName to its name

tell application "System Events"
   tell application process frontAppName
      set frontWindowName to name of front window
   end tell
end tell
Directly Export … AppleScript[2]
# Auth: Christopher Stone <>
# dCre: 2023/01/02 22:42
# dMod: 2023/01/02 22:42 
# Appl: Microsoft Word 16.16.27
# Task: Save Active Document as a PDF with Same Name in Same Directory.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Save, @Active, @Document, @PDF

   tell application id ""
      set activeDoc to active document
      tell activeDoc
         set docName to its name
         set docPath to its path
      end tell
      set newPath to docPath & ":" & docName
      if my folderExists(newPath) is false then
         error "Parent Folder Does Not Exist!"
      end if
      if newPath ends with ".docx" then
         set newPath to text 1 thru -6 of newPath
      end if
      set newPath to newPath & ".pdf"
      save as activeDoc file name newPath file format format PDF
   end tell
on error errMsg number errNum
   set errMsg to errMsg & linefeed & linefeed & "Num: " & errNum
   if errNum ≠ -128 then
         tell application (path to frontmost application as text) ¬
            to set ddButton to button returned of ¬
            (display dialog errMsg with title ¬
               "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
               default button "OK" giving up after 30)
         if ddButton = "Copy Error Message" then set the clipboard to errMsg
      end try
   end if
end try

on folderExists(folderPathHFS)
   tell application "System Events"
      return exists of disk item folderPathHFS
   end tell
end folderExists

Wow! Chris
That's a lot to digest and thanks heaps for the scripts. I think my brain would have had a hernia trying to figure that out.
Keep you posted.

Run the AppleScripts from Apple's Script or better yet Script Debugger.

(The commercial version runs as a demo and then reverts to a SD-Lite which is still way more powerful that the Apple SE.)

The direct export script works in a flash.

Run AppleScripts from Keyboard Maestro using the Execute an AppleScript action.

Hi Chris,

Apologies if this takes the wind out of your sail but just as I figured out how to implement your script and test run it, the latest update of MS word has restored the filename retention.

However, I offer my thanks yet again for assisting with something that I'd have no hope of figuring out myself. AND... I have the script copied neatly away for the next time MS messes with Word!

Humble respect and gratitude,


You may be delighted to hear that Microsoft has again updated Office and I'm back to untitled documents when PDF'ing. So I have set up your code to run in KM as execute Applescript and hey presto, better than ever!

Thank you once again for your help.

1 Like