【发布时间】:2017-08-23 21:29:46
【问题描述】:
我正在尝试将值添加到由工作表上的宏创建的组合框。组合框已创建,但我无法在其中填充数据。
我明白了
运行时错误 438:对象不支持此属性...
我尝试将 sComboBox 声明为形状/对象/也将其留空,但无济于事。 .list 属性上的代码错误。 VBA 智能感知也不会选择 .list 属性。我也尝试使用 OLEObjects,但我得到了不同的编译器错误。
另一个问题是:如何在特定单元格中创建组合框,使它们不会四处浮动或相互重叠?
Dim sComboBox
If (wsTO.Cells(intLoopCounter, 5).Value <> "") Then
cBoxName = "cBox" & wsTO.Cells(intLoopCounter, 5).Value
Set sComboBox = wsTO.Shapes.AddFormControl(xlDropDown, Left:=Cells(intLoopCounter, 12).Left, _
Top:=Cells(intLoopCounter + 1, 12).Top, Width:=250, Height:=25)
With sComboBox
.Name = cBoxName
.List = Array("Apple", "Orange")
End With
End If
【问题讨论】:
-
当智能感知不存在时,在 vbe 中按 F2。您是否尝试过使用显式选项编译代码?