Change Page Setup params through GUI Scripting for OmniGraffle Pro 5

Hello,

I have been trying to figure out how to set some of the values of the “Page Setup” window through GUI Scripting in AppleScript in OmniGraffle Professional 5. From what I have been told by OmniGroup Tech Support, there is currently no way to this through the commands available within the OmniGraffle AppleScript Dictionary, so I have been trying to do this with GUI Scripting.

I have written a script that from what I can tell is supposed to work properly as it does open the “Page Setup” window and gets me to the right menus. The problem is that when I try to actually set the value of the pop up button, it just errors out and says the index is invalid. Has anyone done this before or maybe point out an error in my script that I might be overlooking? Thanks.

activate application “OmniGraffle Professional 5”
tell application “System Events”
tell process “OmniGraffle Professional”

tell menu item “Page Setup.” of menu 1 of menu bar item “File” of menu bar 1
click
tell pop up button 3 of sheet 1 of window 1
click
tell menu 1
click menu item “Any Printer”
end tell

end tell

end tell
end tell
end tell

Model: Mac Pro 8-Core
AppleScript: 2.1.2
Browser: Firefox 3.0.19)
Operating System: Mac OS X (10.6)

2 ideas for you.

click (first menu item whose title is “Any Printer”)

-or-

If “Any printer” is the 5th menu item in the menu then…
click menu item 5

This worked for me…

activate application "OmniGraffle Professional 5"
tell application "System Events"
	tell process "OmniGraffle Professional"
		click menu item 17 of menu 1 of menu bar item "File" of menu bar 1
		click pop up button 3 of sheet 1 of window 1
		click menu item "Any Printer" of menu 1 of pop up button 3 of sheet 1 of window 1
	end tell
	
end tell