VBA Active-X buttons getting bigger with every act

2019-07-27 15:34发布

I have an Excel sheet containing multiple Active-X buttons. Whenever I click on a button/perform an action, the buttons will keep getting bigger with every action.

Initially this didn't happen at my desk (laptop in dock with two big screens), but when I moved and used the program just on my laptop, it suddenly started happening. The only fix I found is to hard-wire the positions right in the code. I feel that there has to be a solution.

Below is a sample of my code.

Private Sub SpinButton1_SpinDown()

Dim myCell As Range
Dim myRange As Range
Set myRange = Selection


SpinButton1.Height = 45
SpinButton1.Width = 39
SpinButton1.Left = 283.5
SpinButton1.Top = 328.5

For Each myCell In myRange
    myCell.Value = myCell.Value - 1
Next myCell


End Sub

2条回答
beautiful°
2楼-- · 2019-07-27 16:01

I have this same issue. It is very sporadic. I have two Excel workbooks with similar buttons on each. This only happens on one of them, but it happens every time I open it. I have found a sort of work-around. I open a blank Excel document, then I open the affected one and the buttons do not change size any more. When I open the second one, I have to drag it into the window with the already-open file. If I double-click on it, it opens in a new window and the problem remains.

查看更多
何必那么认真
3楼-- · 2019-07-27 16:09

It is a Microsoft bug in some versions of Office. Not 100% sure if your version is affected, but you can check here: http://support.microsoft.com/kb/2598259

The fix is also available for download from there.

Also, it is not advisable to use ActiveX buttons unless you want to make colorful buttons with fancy decorations. Even then you can replicate the same effect using

  • Images which look like the buttons you want (with shadows and all for the 3D effect)
  • Setting MouseOver tooltips for the correct look and field for buttons
  • Assigning Macros for Click-behavior, etc.
查看更多
登录 后发表回答