Name
form
.Zoom [= setting
]
Synopsis
Sets or returns the percentage to scale the contents of the form or frame by. Must be between 10 and 400. Zoom doesn’t change the size of the form or frame. The following code zooms in or out on a background picture depending on which mouse button is pressed:
Private Sub UserForm_Initialize( ) ' Load a background picture. Me.Picture = LoadPicture(ThisWorkbook.Path & "\turtle.jpg") ' Change mouse pointer. Me.MousePointer = fmMousePointerCustom Me.MouseIcon = LoadPicture(ThisWorkbook.Path & "\magnify.ico") End Sub Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift_ As Integer, ByVal X As Single, ByVal Y As Single) On Error Resume Next ' If left button, zoom in. If Button = 1 Then Me.Zoom = Me.Zoom * 1.1 ' If right button, zoom out. ElseIf Button = 2 Then Me.Zoom = Me.Zoom * 0.9 End If On Error GoTo 0 End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.