Setting default Zoom in Excel 2011 for Mac via VBA

neosn4ke

New Member
Joined
Aug 25, 2011
Messages
3
This question regards Microsoft Excel 2011 for Mac.

Good day to everyone. I am currently using a startup add in, which sets every Excel document I create or open to the particular Zoom level.

Here it is:

ThisWorkbook:
Code:
Private Sub Workbook_Open()
Setup_Windows
End Sub

MyWindowReg Module:
Code:
Dim clsMyWindow As MyWindowClass

Public Sub Setup_Windows()
Set clsMyWindow = New MyWindowClass
End Sub

MyWindowClass Class Module:
Code:
Public WithEvents oApp As Application

Private Sub oApp_WorkbookOpen(ByVal Wb As Excel.Workbook)
With ActiveWindow
.Zoom = 183
End With
End Sub

Private Sub Class_Initialize()
Set oApp = Application
End Sub

What it does is that every time I open an existing workbook or create a new one, it automatically sets Zoom to 183% (this is the exact zoom percentage, that makes everything on screen identical to the printed copy on a 132 ppi MBP17" display).

Problem here is:
It only changes the Zoom setting of the Sheet that is opened first (or is created first in case of new workbooks). When I switch from the first Sheet to any other (or create a new one) - the Zoom setting is 100% (or whatever it was the last time the file was saved).

Question, if I may:
How to modify the code above to make it also automatically change Zoom setting to 183% every single time I switch between Sheets?

Remark:
I know almost nothing about VBA, the code above is borrowed from somewhere around the Internets. I can modify the add in on my own though.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I'm not too sure since I've never dealt with zoom before but you could try
Code:
Sub Test()
    Dim ws As Worksheet
    For Each ws in Worksheets
        ws.Zoom = 183
    Next ws
End Sub

Try running this and see if it changes all the worksheets' zooms.
then we can implement it into your code.
 
Upvote 0
I don't think it worked.

But then again, I'm not really sure if I do it right.

What I did is I pasted your code into my Class Module, saved it and tried switching Sheet tabs. No luck.
 
Upvote 0
There are other events that you can add (with the same code). Here are a relevant few from the right hand dropdown in the Visual Basic editor when oApp is selected from the left hand dropdown:

oApp_WorkbookNewSheet
oApp_SheetActivate
oApp_WindowActivate
 
Upvote 0
Sheet_Activate sounds like the event that I would use.

Alternatly, you could use Mac OS's Universal Access to zoom larger. That would not be Excel specific.
 
Upvote 0
Compile error in string:

Code:
        ws.Zoom = 183

To be specific, the
Code:
.Zoom
part.

The error reads:
Method or data member not found.

And it didn't work.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,278
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top