运行 VBA 宏,有时效果很好。但在某些情况下,我收到以下错误。
我已经调试了代码,但没有收到任何错误。代码如下。
Public Sub Adjust_ComboBox()
On Error GoTo Adjust_ComboBox_Err
Dim mes As Form
Set mes = [Form_Treatment Details]
Dim count As Long
On Error Resume Next
For Each ctl In mes.Detail.Controls
If TypeName(ctl) = "ComboBox" Then
Dim comboitems() As Variant
count = 1
comboitems = ctl.Value
count = UBound(comboitems) + 1
ctl.Height = (300 * count)
Erase comboitems
End If
Next
Adjust_ComboBox_Exit:
Exit Sub
Adjust_ComboBox_Err:
MsgBox Error$
Resume Adjust_ComboBox_Exit
End Sub
怎么可能得到这个错误?
