Excel VBA ComboBox 下拉按钮大小——改变了自己 [英] Excel VBA ComboBox DropDown Button Size--changed itself

查看:36
本文介绍了Excel VBA ComboBox 下拉按钮大小——改变了自己的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作簿,里面有几个组合框(和列表框)和很多围绕它们写的 vba.我在 Workbook_Open 过程中使用了相同的代码来格式化它们数周,没有任何大问题.

I have a workbook with several comboboxes (and listboxes) and a lot of vba written around them. I've used the same code in the Workbook_Open procedure to format them for weeks, without any major trouble.

昨晚我远程桌面到我的工作计算机(这是有史以来第二次)来编辑代码的其他一些部分(根本没有触及框属性).一段时间后,所有框、列表和组合的格式都变得疯狂.列表框右侧的滚动条变大了,底部也出现了巨大的滚动条.组合框上的下拉按钮也变得很大——和框一样宽.

Last night I remoted-desktopped in to my work computer (for the 2nd time ever) to edit some other parts of the code (nothing that touched the box properties at all). At one point after a while, the formatting of all the boxes, list and combo, went crazy. The right side scroll bars on the list boxes got huge, and huge scroll bars appeared at the bottom of them too. And the Dropdown button on the comboboxes got huge too--as wide as the box just about.

我关闭并重新打开 Excel,所有的框都回到了以前的快乐状态,除了一个,它仍然有一个与框一样宽的下拉按钮.我的 vba 格式代码没有帮助.重新启动计算机没有帮助.我比较了两个应该相同的框的属性窗口(名称和左位置除外),那里没有什么不同.

I closed and reopened Excel, and all the boxes went back to their former happy state, except for one, which still has a dropdown button as wide as the box. My vba formatting code doesn't help. Rebooting the computer doesn't help. I compared the properties window for two boxes that should be identical (except for name and left position), and nothing is different there.

那么无论如何我可以驯服、重置或以其他方式控制这个叛逆的下拉按钮?我希望我什至不在 Excel 中处理这种不可预测的行为,但我被卡住了.

So is there anyway I can tame, reset, or otherwise control this renegade dropdown button? I wish I wasn't even in Excel dealing with this kind of unpredictable behavior, but I'm stuck.

这是我的格式 vba:

Here is my formatting vba:

    With ThisWorkbook.Sheets(c_stMatrixSheet).OLEObjects(c_stMatrixTypeBox)

        .Width = 120
        .Top = 14
        .Left = 878

        Call FormatComboBox(.Object)

        .Object.AddItem c_stAMatrix
        .Object.AddItem c_stBMatrix
        .Object.AddItem c_stCMatrix

        .Object.Text = c_stAMatrix

    End With

...

Private Sub FormatComboBox(bxComboBox As msforms.ComboBox)

    With bxComboBox

        .Clear

        .Height = 19.5
        .Font.Name = c_stDropBoxFont
        .Font.Size = 10
        .AutoSize = False
        .Enabled = True
        .Locked = False

        .Placement = xlFreeFloating

    End With

End Sub

推荐答案

您遇到了在 Worksheets 上使用 ActiveX 控件的问题,我也遇到了同样的问题,它是间歇性的,并且是随机的.

You've run into the problem of using ActiveX controls on Worksheets, I've had the same problem and it is intermittent and randomly does it.

我发现真正解决问题的唯一方法是使用表单控件.这些在工作表上更加稳定,尽管在智能感知中隐藏,除非您选择显示隐藏的对象.它们也非常灵活并提供大量功能 - 除非您需要事件,因为它们不会触发它们.

The only way I've found to truly fix things is to use forms controls. These are much more stable on worksheets although hidden from intellisense unless you choose to show hidden objects. They are also quite flexible and offer a good deal of functionality - unless you need events as they don't fire them.

这篇关于Excel VBA ComboBox 下拉按钮大小——改变了自己的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆