While acquiring the handle to a UserForm will yield an unambiguous result, this can not always be said for the child controls.

Spy++ only finds two child windows.

Obviously, a container holds all child controls, preventing 'FindWindow' or EnumChildWindow' from receiving meaningful results.

In order to still acquire a handle to the control, use following trick:

  • activate the control with 'SetFocus'
  • get the handle using the Api function 'GetFocus'

But: The handles for all buttons are identical. The same applies to Option Box and Check Box handles.


Control Type  Result
 Label  Ambiguous
 TextBox  Ambiguous
 ComboBox  Ambiguous
 ListBox  Unique
 CheckBox  Ambiguous
 OptionButton  Ambiguous
 ToggleButton  Ambiguous
 Frame  Unique
 CommandButton  Ambiguous
 TabStrip  Ambiguous
 MultiPage  Unique
 ScrollBar  Ambiguous
 SpinButton  Ambiguous
 Image  Ambiguous
 TreeView  Unique
 ProgressBar  Unique















In other words: The Api can only be used with following VBA-Controls:

  • ListBox
  • Frame
  • MultiPage
  • TreeView
  • ProgressBar

Please note: The controls handle will change with every call to SetFocus/GetFocus.

Go to top