IntelliSense (autocomplete) is wrong here. If you look at the Properties pane (F4) and the Object Browser (F2), you'll see that there is no RowSourceType property:
Setting Userform ListBox Headings
I'm writing a VBA add-in in Word for Windows to make Content Controls available in Word for Mac.
In the Content Controls Properties dialogs for ComboBox and Drop-down, the list displays headings for Display Name and Value:
I'm trying to duplicate this effect in my userform ListBox. Word VBE autocomplete gives me .RowSourceType for the list box and I've set it to "Value List" as Microsoft documentation suggests. However, when I run it, I get a Type Mismatch error. All the online mentions of this property are for Access, nothing for Word.
When I comment out the RowSourceType line, then .RowSource raises an error "Run-time error '380': Could not set the RowSource property. Invalid Property value." I get a similar error when I try to set the RowSource value in the VBA Properties panel.
With ListDropDown
.RowSourceType = "Value List"
.RowSource = "Display Name;Value"
.ColumnCount = 2
.ColumnHeads = True
.ColumnWidths = "90;75"
.List = ListArray()
End With
Is this another case of Microsoft's ghost commands that exist only in autocomplete/documentation, but not in real life? What are the common workarounds?
Microsoft 365 and Office | Word | For business | Windows
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
-
HansV 462.4K Reputation points MVP Volunteer Moderator2023-05-07T18:09:43+00:00 The RowSource is only valid in Excel, where you can set it to a range address. The same goes for the ControlSource property.
And the ColumnHeads property can only be set to True in Excel.
Since all Office applications share the same MSForms library, you'll see these methods in all of them, even if you cannot use them,
The inclusion of RowSourceType is a real bug though - that is a property of an Access list box, which is a completely different control than the userform list box.
5 additional answers
Sort by: Most helpful
-
-
HansV 462.4K Reputation points MVP Volunteer Moderator2023-05-07T20:53:16+00:00 Yeah, I wasn't precise enough. You can set the property to True, but there is no way to populate the headings,
In Excel, they are taken from the row above the range that acts as RowSource,