Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set Excel 2008 default zoom level via AppleScript Apps
I had a client ask how to set the zoom for new and existing documents to something larger than 100% in Excel 2008 because he finds it too difficult to read at the default size. While my vision may be a tad better, I still find the Mac version of Excel to be on the small side. Sure, the preferences allow for the setting of a default font and size for new documents, but this will alter printouts and returns us to our problem. The "simple" answer I came up with is an AppleScript "assistant" for zooming that runs in the background and quits when it senses Excel is not running.

You can also drop files on it as a replacement for the Excel icon in your Dock! You can either download the script [24KB], or read the rest of this hint to view the source.

[robg adds: I've also provided an alternative solution that's not nearly as elegant, but which works for me, in the remainder of the hint.]

Here's the code...
(*
This code was originally written by Mike Cramer on 2008-05-29.  Email me at kiodane at [Google's mail service] dot com
*)

property zoomFactor : ""
property prevWinNameList : {}

--------------------------------------------

on open theseFiles
  tell application "Microsoft Excel" to open theseFiles
  initializeZoomFactor()
end open

--------------------------------------------

on run
  initializeZoomFactor()
end run

--------------------------------------------

on idle
  
  --Find out if Excel is still running.
  tell application "System Events" to set ExcelIsRunning to (name of processes) contains "Microsoft Excel"
  
  if ExcelIsRunning then
    try
      tell application "Microsoft Excel"
        
        --Get the currently open windows.
        set currWinNameList to name of every window
        set currWinList to every window
        
        repeat with anWindow in currWinList --i from 1 to (count of currWinList)
          
          --Compare current windows to the last check  
          if prevWinNameList contains name of anWindow then
          else
            tell anWindow to set zoom to zoomFactor
          end if
          
        end repeat
        
        --The current windows are next check's old windows.        
        set prevWinNameList to currWinNameList
        
      end tell
    end try
  else
    --When Excel quits, the assistant should quit too.
    quit
  end if
  
  --repeat every 5 seconds.
  return 5
end idle

--------------------------------------------

on initializeZoomFactor()
  
  --Make sure Excel is running to begin with.
  tell application "Microsoft Excel" to activate
  
  set errMsg to ""
  set output to 0
  repeat while (output < 25 or output > 400) --The range of Excel's zoom is 25-400%
    
    activate
    
    display dialog errMsg & "Please enter a Zoom Factor to use with all documents in Excel (25-400):" default answer zoomFactor buttons {"Okay", "Nevermind"} default button 1
    copy the result as list to {text_returned, button_pressed}
    
    
    if button_pressed = "Okay" then
      
      --Verify the entered text can be converted to a number.
      set output to 0
      try
        set output to text_returned as number
      end try
      
      --Check the number is within range
      if (output ≥ 25 and output ≤ 400) then
        set zoomFactor to output as number
      else
        set errMsg to "There was an error with your last input.rr"
      end if
    else
      quit
    end if
  end repeat
  
  --For some reason Excel likes to hide at a previous step sometimes.  This line fixes that:
  tell application "Microsoft Excel" to activate
  
end initializeZoomFactor
[robg adds: I searched the net for a simpler way to make all documents appear at a higher zoom level, but didn't find an easy answer. You can modify the Normal template, I believe, to force new documents to appear at your chosen zoom level, but that won't affect existing documents. You can, of course, use the mouse to zoom the sheet -- Control-Command and scroll wheel in 10.5 will increase or decrease the zoom level. The control isn't all that precise, though, and you have to scroll very slowly to find the exact zoom level you want. As an alternative, you can create keyboard shortcuts for zoom in and zoom out, which is what I've done.

Go to Views » Customize Toolbars and Menus, then click on the Commands tab. Click on All Commands in the left-side box, then scroll down and find Zoom In in the right-hand box.

Now drag Zoom In from that dialog up to the small representation of the main menu that appears just below the actual menu bar. Drag and drop it onto a menu where you'll be able to find it -- I placed it at the bottom of the View menu. Click OK to close the dialog in Excel, then open the Keyboard Shortcuts tab of the Keyboard & Mouse System Preferences panel. Click the plus sign to add a new shortcut, set Excel 2008 as the application and Zoom In as the menu title. Enter the shortcut you'd like to use (Control-Option-plus or whatever), and (if you're running 10.5) switch back to Excel 2008 and try your new shortcut. (For previous versions of OS X, you'll need to quit and relaunch Excel to see the new shortcut.)

Repeat the above steps for Zoom Out (Control-Option-minus), and you've got handy shortcuts to precisely set the zoom levels. While this method isn't as elegant as the above AppleScript, it works pretty well for my needs.]
    •    
  • Currently 2.17 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[18,691 views]  

Set Excel 2008 default zoom level via AppleScript | 7 comments | Create New Account
Click here to return to the 'Set Excel 2008 default zoom level via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set Excel 2008 default zoom level via AppleScript
Authored by: incogenator on May 30, '08 10:16:56AM

thanks for this tip but i have been looking for a way to get excel for mac 2008 to open at the same spot it was on when i closed it. i cannot get it to save the view to anything besides the default (a1) home position.

any thoughts or hints?



[ Reply to This | # ]
Set Excel 2008 default zoom level via AppleScript
Authored by: dillfest on May 30, '08 02:15:25PM

Would this work for word as well, if all the program names are changed?



[ Reply to This | # ]
Set Excel 2008 default zoom level via AppleScript
Authored by: jpfour23 on May 31, '08 07:47:37PM

Love it. Worked great for me. However, I would love to do the same thing for Word. I can't stand Word opening up at 100%. 150 or 200 would be awesome. Any ideas?



[ Reply to This | # ]
Set Excel 2008 default zoom level via AppleScript
Authored by: relewis1 on Jun 02, '08 11:27:37AM

Ok, as a newbie how do I remove this after trying it out?



[ Reply to This | # ]
Set Excel 2008 default zoom level via AppleScript
Authored by: ede on Aug 06, '08 01:05:05PM

Another way of doing this is to modify the startup template. Get everything just like you like it (zoom, window positions, etc.), then Save As...
1. Format: "Excel Template (.xltx)"
2. Name: "Workbook" with no quotes and no extension. If Excel automatically adds the extension .xltx in the "Save As" dialog, delete the extension. This is critical!
3. Location: in the Excel Startup folder, located by default at HD:Applications:Microsoft Office 2008:Office:Startup:Excel

Of course this won't affect existing spreadsheets, but it can save time when creating new ones.



[ Reply to This | # ]
Set Excel 2008 default zoom level via AppleScript
Authored by: terry1694 on Oct 01, '10 08:26:09PM

This AppleScript worked perfectly for me and I am so grateful. I had previously tried using the technique suggested by "ede on Aug 06, '08 01:05:05PM" numerous times, without success. Thank you.



[ Reply to This | # ]
Set Excel 2008 default zoom level via AppleScript
Authored by: noahjz on Dec 02, '10 07:21:17AM
ede's comment above does work to set a default zoom level for new windows, but there was an extra step for me to get it to work. The part about making absolutely sure the suffix is not part of the file name was trickier than it seems. To get it work I had to:

1. Change the finder prefs (not system preferences) then select "show all filename extensions." I am not positive but I think this defaults to off, which makes the finder automatically hide extensions, so you think you've saved your excel template "workbook" without an extension but really it is just hidden.

2. Manually remove the .xltx from the file name in the finder.

3. Quit and re-launch excel.

As pointed out by the original hinter, this won't fix the zoom problem for old saved files, but it will make new windows zoomed, which is good enough for me.

I am pretty annoyed at how difficult Microsoft makes this basic preference configuration, and a little surprised that nobody is bashing Microsoft about it. I searched Excel Help within the program and searched the MS website and found nothing from Microsoft on how to fix this (although there were several windows-specific solutions which did not apply to OS X). It is sort of insane that to fix a user-interface design flaw which has existed in this software for as many versions as I can remember using, it was easier for someone to write a script than to find out the "right" way, i.e. adding a workbook.xlxt to startup folder (although obviously this is less functional than the script, in that the script will auto-zoom old excel files). I don't mean anything negative against the scripter, and kudos to him or her, it is just a reflection on how horrible Microsoft's support is.

[ Reply to This | # ]