Hey Russell,
There is no such action – however there are methods of doing this.
- FrontWindowName token
- Plus brute-force actions emulating user interaction.
- Finding the File Path for the Front Document in the Front Application
- Plus brute-force actions emulating user interaction.
- AppleScript
- Get the name of the front window of the front app.[1]
- Plus brute-force actions emulating user interaction.
- Directly export from Word to PDF – bypassing dialogs.[2]
- My preference
- Get the name of the front window of the front app.[1]
-Chris
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 <scriptmeister@thestoneforge.com>
# 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
--------------------------------------------------------
try
tell application id "com.microsoft.Word"
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
try
beep
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
--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on folderExists(folderPathHFS)
tell application "System Events"
return exists of disk item folderPathHFS
end tell
end folderExists
--------------------------------------------------------