I have a comboBox on an excel spreadsheet, and I want to open (expand) the dropdown list when the user clicks in the editable area. I have the following code, but it doesn't work:
Private Sub Wordbox_GotFocus()
Dim retv as long
retv = SendMessageLong(Wordbox.hwnd, CB_SHOWDROPDOWN, True, 0)
This code fails because VBA doesn't have a hwnd property for combo boxes, so the first parameter causes an error.
I tried to get the comboBox's handle like this:
Dim TheHandle As Long
TheHandle = FindWindow("ComboBox", "Wordbox")
But the FindWindow API returned zero. (Probably I didn't send the right parameter values, but I don't know what to send.
(Yes, I have the API declarations -- omitted for brevity.)
Can anyone tell me how to open the list when a VBA combobox gets focus?