Dayo Mitchell said:
Recording the macro gets you this:
Sub Zoom110()
'
' Zoom110 Macro
' Macro recorded 12/13/03 by Dayo Nicole Mitchell
'
ActiveWindow.ActivePane.View.Zoom.Percentage = 110
End Sub
Which looks pretty clean. Assign a toolbar button (though you will likely
want to draw one in pixels since the provided icons are *so* unhelpful, I
think).
Unless I missed some hidden complexity in your question?
That's exactly how I would have gone about writing it...
Often a recorded macro needs some editing to make it more applicable
to a general situation. In this case, it doesn't.
But, liking to build all my toolbars from scratch on startup, I then
would store the macro in my my_startup.dot global macro, write
another one that restores the zoom to 100%, and insert this into my
toolbar routine:
With CommandBars("My Workbar").Controls
'lots of other controls
With .Add(Type:=msoControlButton)
.BeginGroup = True
.FaceId = 941
.OnAction = "Zoom110"
.TooltipText = "Zoom to 110%"
End With
With .Add(Type:=msoControlButton)
.BeginGroup = False
.FaceId = 2122
.OnAction = "Zoom100"
.TooltipText = "Zoom to 100%"
End With
End With
Or, what I'd usually do if I were feeling a bit fancy, is make a
toggle macro that alternates between 100% and 110% (and changes
button faces depending on the alternative), making use of the
button's .Parameter property:
With CommandBars("My Workbar").Controls
'lots of other controls
With .Add(msoControlButton, temporary:=True) 'Zoom
.FaceId = 941
.OnAction = "ZoomIt"
.Parameter = 110
.TooltipText = "Zoom to 110%"
.Tag = "ZoomToggle"
End With
'other controls
End With
Then instead of the Zoom110() and Zoom100() macros, I'd make one
macro that uses the button's .Parameter property to determine the
zoom, then switches the parameter, icon and tooltip properties for
the button:
Public Sub ZoomIt()
Dim nParm As Integer
nParm = CommandBars.ActionControl.Parameter
ActiveWindow.ActivePane.View.Zoom.Percentage = nParm
nParm = 210 - nParm 'Toggle between 100% & 110%
With CommandBars.FindControl(Tag:="ZoomToggle")
.Parameter = nParm
.FaceId = IIf(nParm = 100, 2122, 941)
.TooltipText = "Zoom to " & nParm & "%"
End With
End Sub
But neither are too different from what Dayo wrote.
Note: to toggle between other zoom values, change the
nParm = 210 - nParm
line. For instance, replacing 210 with 275 will toggle between 100%
and 175%.
BTW: The FaceID=941 is a pair of glasses - which seems appropriate
to me for increasing the zoom. The FaceID=2122 is "100%".
Unfortunately, there's no FaceID for 110% (but there are for
25%,50%, and 75%).