Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AppleScript Page Setup and Paper Size

226 views
Skip to first unread message

msuw...@officeformac.com

unread,
Mar 12, 2010, 10:51:14 PM3/12/10
to
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel 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 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!

msuw...@officeformac.com

unread,
Mar 25, 2010, 11:19:55 AM3/25/10
to
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

freestat...@gmail.com

unread,
Jul 6, 2017, 8:19:53 PM7/6/17
to
Old thread but it still might help someone. It's been many days for me trying to figure this out. I used the following AppleScript to set a new page size because Excel 2011 won't remember it.

tell application "Microsoft Excel"
activate
end tell

tell application "System Events"
delay 0.5
--keystroke "a" using command down
tell application process "Microsoft Excel"
click menu item "Page Setup..." of menu "File" of menu bar item "File" of menu bar 1
delay 0.5
keystroke "o" using command down --This clicks the Option... button
delay 0.5
click pop up button 3 of window "Page Setup" --This clicks the Paper Size: drop down. button 2 clicks the Format For: drop down
delay 0.5
keystroke "4" --Use the first couple of letters of your desired page size. For me it was 4" x 2-1/2" tag
keystroke return --Hit enter a couple times to close the dialog boxes
delay 0.5
keystroke return
delay 0.5
keystroke return
delay 0.5
end tell
end tell
0 new messages