tell application "Microsoft Word" to activate
tell application "System Events"
tell application process "Microsoft Word"
click menu item "Print..." of menu "File" of menu bar item "File" of menu bar 1
delay 0.5
click button 4 of UI element 5 of window 1
end tell
end tell
--
delay 1
--
tell application "Preview" to activate
tell application "System Events"
tell application process "Preview"
click menu item "Print…" of menu 1 of menu bar item "File" of menu bar 1
delay 0.5
click at position of UI element 1 of UI element 6 of UI element 4 of sheet 1 of window 1
delay 0.2
key code {125, 49}
delay 1
-- if new file name is needed, enter the pdf name into the Save dialog's text field
set value of text field 1 of window 1 to "test2.pdf"
delay 0.5
-- use Control-d to set the desktop as the destination
keystroke "d" using command down
delay 0.5
click button "Save" of window "Save"
delay 0.2
end tell
end tell