Reputation: 3167
Any ideas why this works (VBA, Excel 2007):
ThisWorkbook.Worksheets("Sheet1").OLEObjects(controlId).ListFillRange = ""
but this doesn't:
ThisWorkbook.Worksheets("Sheet1").OLEObjects(controlId).AddItem ("xyz")
I don't remember how I solved this before. Right now it says object doesn't support this property or method (it's a combobox).
PS: This is very strange; I tested an old procedure that worked well as far as I can remember, and now it fails, inexplicably. It also contains a reference like this:
MsgBox ThisWorkbook.Worksheets("Sheet1").toggleBtn.Caption
Upvotes: 0
Views: 4034
Reputation: 22842
You need to reference the Object itself to use the AddItem property.
ThisWorkbook.Worksheets("Sheet1").OLEObjects(controlId).Object.AddItem ("xyz")
Upvotes: 3