VBA Active-X buttons getting bigger with every action

感情迁移 提交于 2020-01-15 11:49:08

问题


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

回答1:


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.



回答2:


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.



来源:https://stackoverflow.com/questions/24682545/vba-active-x-buttons-getting-bigger-with-every-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!