VBA Active-X 按钮随着每个动作变大
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24682545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Active-X buttons getting bigger with every action
提问by DeeWBee
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.
我有一个包含多个 Active-X 按钮的 Excel 工作表。每当我点击一个按钮/执行一个动作时,按钮会随着每个动作不断变大。
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
采纳答案by hnk
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
这是某些版本的 Office 中的 Microsoft 错误。不能 100% 确定您的版本是否受到影响,但您可以在此处查看: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
此外,不建议使用 ActiveX 按钮,除非您想制作带有花哨装饰的彩色按钮。即使这样,您也可以使用复制相同的效果
- 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.
- 看起来像您想要的按钮的图像(带有阴影和全部用于 3D 效果)
- 为按钮的正确外观和字段设置鼠标悬停工具提示
- 为点击行为等分配宏
回答by RPh_Coder
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.
我有同样的问题。这是非常零星的。我有两个 Excel 工作簿,每个工作簿上都有类似的按钮。这只发生在其中一个上,但每次打开它时都会发生。我找到了一种解决方法。我打开一个空白的 Excel 文档,然后打开受影响的文档,按钮不再改变大小。当我打开第二个时,我必须将它拖到带有已打开文件的窗口中。如果我双击它,它会在一个新窗口中打开,但问题仍然存在。