vba Excel 按钮增长
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11530978/
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
Excel Button Growing
提问by Brendan Foote
I'm working on a workbook in Excel 2010 that someone else created (I don't know which version they were using) with a button in it that invokes a macro. There are a lot of macros defined, so I'm right-clicking on it to find out which one it calls, but the context menu doesn't appear. Instead, when I click off, the button gets larger. I can make this happen as many times in a row as I'd like. There is another button the same worksheet that has the same context menu problem, but instead of growing, the text shrinks each time. There is another button that functions normally when I do this.
我正在 Excel 2010 中处理其他人创建的工作簿(我不知道他们使用的是哪个版本),其中有一个调用宏的按钮。定义了很多宏,所以我右键单击它以找出它调用的是哪一个,但是上下文菜单没有出现。相反,当我点击关闭时,按钮会变大。我可以根据需要连续多次发生这种情况。同一工作表中还有另一个按钮具有相同的上下文菜单问题,但文本每次都缩小而不是增长。当我这样做时,还有另一个按钮可以正常工作。
采纳答案by ray
I think you want to enter "Design Mode" in the work book:
我想你想在工作簿中进入“设计模式”:
You should be able to right-click on the button to see what it does after that.
您应该能够右键单击该按钮以查看它之后的操作。
回答by Jon Crowell
Growing buttons in Excel is a fairly common issue, with several theories about why this happens, including the use of multiple monitors or using proportional fonts. I have yet to see a definitive answer about this, but there are several workarounds that may work for you.
在 Excel 中增加按钮是一个相当普遍的问题,有几种关于为什么会发生这种情况的理论,包括使用多个显示器或使用比例字体。我还没有看到关于这个的明确答案,但有几种解决方法可能对你有用。
- Delete and re-create the buttons.
- Programmatically set the height and width of the buttons when the workbook is opened and when a button is clicked.
- Select the button with another object or two on the sheet and group them.
- Don't use them at all.
- 删除并重新创建按钮。
- 打开工作簿和单击按钮时,以编程方式设置按钮的高度和宽度。
- 在工作表上选择带有另一个或两个对象的按钮并将它们分组。
- 根本不要使用它们。
My personal choice is #4. As an alternative to buttons, I either use hyperlinks or shapes with macros assigned to them.
我个人的选择是#4。作为按钮的替代方案,我要么使用超链接,要么使用分配了宏的形状。
回答by RPh_Coder
I have this same issue. I have two Excel workbooks with similar buttons on each. This only happens on one of them, but it happens every time I open that file.
我有同样的问题。我有两个 Excel 工作簿,每个工作簿上都有类似的按钮。这只发生在其中一个上,但每次打开该文件时都会发生。
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 文档,然后打开受影响的文档,按钮不再改变大小。当我打开第二个时,我必须将它拖到带有已打开文件的窗口中。如果我双击它,它会在一个新窗口中打开,但问题仍然存在。
回答by R Neame
I have the same issue sometimes. In my case, I could replicate it 100% on one file but it was inconsistent on an virtually identical file. I also found the size error wasn't permanent -- I could save and reopen the file to restore the button's appearance. I could also create a new window and then discard the damaged window.
我有时也有同样的问题。就我而言,我可以在一个文件上 100% 复制它,但在几乎相同的文件上却不一致。我还发现大小错误不是永久性的——我可以保存并重新打开文件以恢复按钮的外观。我也可以创建一个新窗口,然后丢弃损坏的窗口。
For me, the button resized when I accessed the sheet's HPageBreakscollection. I was able to avoid the problem by temporarily changing the window view as follows:
对我来说,当我访问工作表的HPageBreaks集合时,按钮会调整大小。我可以通过临时更改窗口视图来避免这个问题,如下所示:
ActiveWindow.View = xlPageBreakPreview
' do pagination stuff using HPageBreaks
ActiveWindow.View = xlNormalView