Excel 2008 AppleScript Page Setup and Paper Size

Hello,

I have been beating my head into the wall to figure this one out. I have created the following AppleScript to set some items in the Page Setup:

tell application “Microsoft Excel”
tell page setup object of active sheet
set page orientation to landscape
set zoom to false
set fit to pages wide to 1
set fit to pages tall to 9999
end tell
end tell

So that seems to work. The problem is I need to also be able to change the Paper Size to US Legal using AppleScript as well. To change it in the GUI, I go to File… Page Setup… Options… {change the paper size to whatever you want} then click OK, OK

Is changing the Paper Size via AppleScript possible?

Instead of AppleScript, I have tried both Automator and QuicKeys… both seem to have trouble with the deeper Page Setup menu (Page Setup… click Options… to get to another Page Setup window).

It seems like Word 2008 has a way to change the paper size via AppleScript, but I’m starting to think it is impossible in Excel 2008.

Thanks for your help!

Just for future people’s FYI (since I had no replies)… I ended up just using QuicKeys (http://www.startly.com/products/quickeys/mac/4/)

The way I got it to work, was I didn’t start recording the QuicKeys shortcut (macro) until I had the second Page Setup dialog box open (File, Page Setup…, Options…). Then after I had all of the steps after that diaglog box recorded, I just manually added the steps to actually open the second Page Setup dialog box in the beginning of the shortcut (File, Page Setup…, Options…)

I also did end up using the AppleScript below as the last piece of the QuicKeys shortcut (you can embed AppleScript in your QuicKeys shortcuts… pretty cool).

tell application "Microsoft Excel"
        tell page setup object of active sheet
                set page orientation to landscape
                set zoom to false
                set fit to pages wide to 1
                set fit to pages tall to 9999
        end tell
end tell

works great… enjoy