点击后VBA Excel中重新调整按钮(命令按钮) [英] VBA Excel Button resizes after clicking on it (Command Button)
本文介绍了点击后VBA Excel中重新调整按钮(命令按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能从调整停止按钮?每次我点击按钮,按钮的规模或字体大小的变化。
How can I stop a button from resizing? Each time I click on the button, either the size of the button or the font size changes.
请注意:我不能锁住我的表作为我的宏将写入到表。
Note: I cannot lock my sheet as my Macro will write into the sheet.
自动调整被关闭。我在Windows 7上运行Excel 2007(64位)。
Autosize is turned off. I run Excel 2007 on Windows 7 (64 Bit).
推荐答案
我用列表框下面。对于按钮同样的原则;适应为宜。
I use the following for ListBoxes. Same principle for buttons; adapt as appropriate.
Private Sub myButton_Click()
Dim lb As MSForms.ListBox
Set lb = Sheet1.myListBox
Dim oldSize As ListBoxSizeType
oldSize = GetListBoxSize(lb)
' Do stuff that makes listbox misbehave and change size.
' Now restore the original size:
SetListBoxSize lb, oldSize
End Sub
本使用下面的类型和程序:
This uses the following type and procedures:
Type ListBoxSizeType
height As Single
width As Single
End Type
Function GetListBoxSize(lb As MSForms.ListBox) As ListBoxSizeType
GetListBoxSize.height = lb.height
GetListBoxSize.width = lb.width
End Function
Sub SetListBoxSize(lb As MSForms.ListBox, lbs As ListBoxSizeType)
lb.height = lbs.height
lb.width = lbs.width
End Sub
这篇关于点击后VBA Excel中重新调整按钮(命令按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文