尝试自动完成ActiveX ComboBox时Excel崩溃 [英] Excel crash when trying to Autocomplete an ActiveX ComboBox

查看:85
本文介绍了尝试自动完成ActiveX ComboBox时Excel崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工作表上有一个ActiveX Combobox控件,这是_Change事件代码

I have an ActiveX Combobox control on a worksheet and this is the _Change event code

Private Sub ComboBox1_Change()
  Me.ComboBox1.ListFillRange = "ItemSearch"
  Me.ComboBox1.DropDown
End Sub

当我使用键盘上/下键在列表中移动时,它会自动退出Excel.

When I use keyboard up/down key to move through the list it automatically quits Excel.

有人知道这个问题的解决方案吗?我基本上想要一个动态的ComboBox.

Does anyone know the solution to this problem? I basically want a dynamic ComboBox.

推荐答案

更改所选选项时,您将强制更新Combobox的可能值,
这就是为什么它崩溃的原因.

You are forcing Combobox's possible values to update when you change the selected option,
that is why it's crashing.

在这种情况下,您可以尝试保留Me.ComboBox1.DropDown.

You can try to keep Me.ComboBox1.DropDown in that event.

但是.ListFillRange应该在另一个事件中:

But the .ListFillRange should be in another event :

  • Workbook_Open
  • Workbook_SheetChange
  • Worksheet_SelectionChange
  • Worksheet_Change

如果您尝试使用某种自动完成行为,则可以使用内置属性:

If you're attempting to have a kind of AutoComplete behavior, you can use a built-in property :

  1. 右键单击控件,再单击属性"
  2. 在打开的属性"窗口中,找到MatchEntry属性
  3. 将其设置为0 - fmMatchEntryFirstLetter
  1. Right-click on the Control, click on Properties
  2. In the opened Properties window, find the MatchEntry property
  3. Set it to 0 - fmMatchEntryFirstLetter

这篇关于尝试自动完成ActiveX ComboBox时Excel崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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