Я должен бросить универсальный объект управления формы VBA в объект ComboBox так, чтобы я мог добавить объекты к нему. Родовой объект не позволит мне вставлять объекты в свои существующие списки
Dim ctlCurrent As MSForms.Control
For Each ctlCurrent In frmItemInput.Controls
If TypeName(ctlCurrent) = "ComboBox" Then
Dim lbCurrentComboBox As MSForms.ComboBox
lbCurrentComboBox = ctlCurrent 'This is where the error occurs, when I try to convert one into another
' Adiciona os itens necessários
lbCurrentComboBox.AddItem ("R")
lbCurrentComboBox.AddItem ("D")
End If
Next ctlCurrent
Моя проблема: у Меня есть тонны ComboBoxes в моей форме, и я должен добавить те же опции для всех них. Таким образом, я хотел бы сделать это progrmatically.
Вы можете "привести" объект VBA с помощью SET, например:
SET lbCurrentComboBox = ctlCurrent