Consulting

Results 1 to 4 of 4

Thread: Activewindow Zoom

  1. #1

    Activewindow Zoom

    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

    [VBA]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

    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What is Zoom here? Are these ActiveX controls on a worksheet?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Zoom is a textbox on a userform.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This works fine for me

    [vba]

    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
    [/vba]

    I would set the max and min on your spinbutton to some sensible values though.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •