need help printing to PDF please

G’day

I’m trying to script printing to a PDF from Word, but the following script doesn’t work using the GUI. The first click doesn’t open the menu, so I can’t tell if the second click will work or not.

Can anyone tell me what I’m doing wrong please?

Thanks

Santa


tell application "System Events" to tell process "Microsoft Word"
	try
		tell UI element 1 of UI element 5 of UI element 5 of window "Print"
			set {xPosition, yPosition} to position
			set {xSize, ySize} to size
		end tell
		-- modify offsets if hot spot is not centered:
		click at {xPosition + (xSize div 2), yPosition + (ySize div 2)} -- The PDF button
		click menu item "Save as PDF..." of UI element 1 of UI element 5 of UI element 5 of window "Print"
	end try
end tell

PS this doesn’t work either.


tell application "System Events" to tell process "Microsoft Word" to tell window "Print"
	try
		tell UI element 1 of UI element 5 of UI element 5
			set {xPosition, yPosition} to position
			set {xSize, ySize} to size
		end tell
		-- modify offsets if hot spot is not centered:
		click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
		click menu item "Save as PDF..." of UI element 1 of UI element 5 of UI element 5
	end try
end tell


Model: G5 1.8 GHz
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

You may have (already) been trying to adapt the script here:

http://bbs.applescript.net/viewtopic.php?id=19194

Print dialogs for different apps (annoyingly) use different UI elements for the critical buttons. I don’t have Word, so can’t help much further.

Good Luck.

Peter B.