PDA

View Full Version : Activewindow Zoom



av8tordude
08-18-2011, 09:46 AM
I have this code that counts up or down. I keep getting an error each time I want to change the number.
The error is: Unable to set the zoom property of the window class. The highlighted error is: ActiveWindow.Zoom = Zoom.value

Private Sub Zoom_Change()
ActiveWindow.Zoom = Zoom.value
End Sub

Private Sub SpinButton1_SpinDown()
Zoom.Value = Format(0, "0")
Zoom.Value = Zoom.Value + SpinButton1.Value / 100
Zoom.Value = Format(Zoom.Value, "0%")
End Sub

Private Sub SpinButton1_SpinUp()
Zoom.Value = Format(0, "0")
Zoom.Value = Zoom.Value + SpinButton1.Value / 100
Zoom.Value = Format(Zoom.Value, "0%")
End Sub

Bob Phillips
08-18-2011, 10:32 AM
What is Zoom here? Are these ActiveX controls on a worksheet?

av8tordude
08-18-2011, 10:41 AM
Zoom is a textbox on a userform.

Bob Phillips
08-18-2011, 11:02 AM
This works fine for me



Private Sub Zoom_Change()
ActiveWindow.Zoom = Val(Replace(Zoom.Value, "%", ""))
End Sub

Private Sub SpinButton1_SpinDown()
Zoom.Value = Format(SpinButton1.Value / 100, "0%")
End Sub

Private Sub SpinButton1_SpinUp()
Zoom.Value = Format(SpinButton1.Value / 100, "0%")
End Sub

Private Sub UserForm_Activate()
Me.SpinButton1.Value = ActiveWindow.Zoom
Zoom.Value = Format(SpinButton1.Value / 100, "0%")
End Sub


I would set the max and min on your spinbutton to some sensible values though.