Excel: the Incredible Shrinking and Expanding Controls

前端 未结 30 2061
予麋鹿
予麋鹿 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:10

    It's very weird. The Width & Height properties don't shrink when queried (either in code or using the properties sheet), but apparently they DO change.

    I noticed that if I use the properties sheet and change the width from the standard 15 to, say, 14 and then BACK to 15, it fixes it.

    The code below works for me (and has an amusing visual effect on the sheet: you click, it shrinks, the screen flickers, and it expands back).

    MY SOLUTION in code (on the click event for the checkbox):

    Dim myCtrl As OLEObject
    For Each myCtrl In ActiveSheet.OLEObjects
      myLab = myCtrl.Name
      myCtrl.Height = 14 ' to "wake up" the property.
      myCtrl.Height = 15 ' to reset it back to normal
      myCtrl.Width = 12 ' just making sure
    Next myCtrl
    

提交回复
热议问题