on open fileList
PrintToPDF(fileList)
end open
on run
set fileList to choose file with prompt "Wähle deine .doc Dokumente aus ... :" with multiple selections allowed
PrintToPDF(fileList)
end run
-- main
on PrintToPDF(fileList)
repeat with myDoc in fileList
if (myDoc as text) ends with ".doc" then
set theNewDefaultPath to (choose folder with prompt "Wähle deinen Zielordner aus" default location path to desktop)
set pdfSavePath to theNewDefaultPath
tell application "Microsoft Word"
activate
open myDoc
end tell
tell application "System Events"
tell process "Microsoft Word"
-- Press command+p to open our print dialog
keystroke "p" using command down
-- Let's make sure our print dialog is up
repeat until exists window "Drucken"
end repeat
-- Click the PDF menu button
click menu button "PDF" of window "Drucken"
-- Make sure the menu is up
repeat until exists menu item "Als PDF sichern …" of menu 1 of menu button "PDF" of window "Drucken"
end repeat
-- Select the "Als PDF sichern" menu item
click menu item "Als PDF sichern …" of menu 1 of menu button "PDF" of window "Drucken"
-- Make sure the save dialog is visible
repeat until exists window "Sichern"
end repeat
-- Press command+shift+g to show the "Go" drop down sheet
keystroke "g" using {command down, shift down}
-- Set our location field to our pdfSavePath
set value of text field 1 of sheet of window "Sichern" to pdfSavePath
-- Now click the Go button
click button "Start" of sheet of window "Sichern"
-- Now that we are in our desired folder, set the file name and save
click button "Sichern" of window "Sichern"
delay 5
-- Press command+q to quit word
tell process "Microsoft Word"
keystroke "q" using command down
end tell
end tell
end tell
end if
end repeat
end PrintToPDF