Howto script "Save to PDF" in Word 2004 ??

Hello All

after quite a while trying to identify the UI elements of Print in Word 2004 I need help to use the “Save to PDF” function inside applescript.
I want to be able to select a word doc file and to get a copy of the same file in pdf format in the same location. Does anybody know how to script “Save to PDF” with Word 2004 ?
below what I try so far

“quote”
tell application “Finder”
set fileName to (choose file “Choose File to convert!”)
open fileName
end tell
delay 5
tell application “System Events”
get properties
tell process “Microsoft Word”
get every UI element
tell menu 1 of menu bar item 3 of menu bar 1
click menu item 16
delay 2
end tell
end tell
tell sheet “Print” of window 1
tell UI element 3 – THE UI ELEMENT ID IS WRONG
click menu button 0
tell menu button 0
click menu item 1 or menu 0
end tell
end tell
end tell
end tell

“unquote”
as the ui element number is wrong I got the "NSReceiverEvaluationScriptError: 4 " error.

any idea or does anybody can identify the UI element NUMBER in the
“Print” window for “Save to PDF” and thereafter in the “Save to File” window for “Save” ?

thx for all help

linus

first off, you have to make sure the “Enable access for assistive devices” item is checked in the Universal Access PreferencePane. then try running this script:

–begin script here
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
– omitting ‘of application process “”’
end tell

tell application "System Events"
	tell application process "Microsoft Word"
		click button "Save As PDF…" of UI element 4 of window "Print"
		-- omitting 'of application process "<name>"'
	end tell
end tell

end tell
–end script here