Excel: the Incredible Shrinking and Expanding Controls

前端 未结 30 2026
予麋鹿
予麋鹿 2020-11-28 04:51

Occasionally, I\'ll happen across a spreadsheet which suffers from magic buttons or listboxes which get bigger or smaller over time.

Nothing in the code is instructi

30条回答
  •  离开以前
    2020-11-28 05:29

    My monitors all appear to be set at native resolutions, which deepens the mystery. However, I have found that doing SOMETHING to the button (moving or resizing) somehow fixes the problem. This routine automates the moving, and then restores the original setting.

    The following code seems to address the problem, at least for buttons.

    Public Sub StablizeButton(oButton As MSForms.CommandButton)
    
        With oButton
    
            ' If True, then temporary distortion is remedied only by clicking somewhere.
            ' If False, then the temporary distortion is remedied merely by moving the mouse pointer away.
            .TakeFocusOnClick = False
            ' For best results:  In the Properties Sheet, initialize to False.
    
            .Left = .Left + 200             ' Move the button 200 units to the right, ...
            .Left = .Left - 200             ' ... and then move it back.
    
        End With
    
    End Sub
    

    Invoke it as follows:

    Private Sub MyButton_Click()
        StablizeButton MyButton
    
        ' Remainder of code.
    End Sub
    

提交回复
热议问题