Subscribe to events in VBA?

后端 未结 1 573
遥遥无期
遥遥无期 2021-01-20 16:09

Did I understood correctly that you can\'t subscribe to an event other than using the VBA Editor\'s control name + event name comboboxes? There is no combobox.change+=eventh

相关标签:
1条回答
  • 2021-01-20 16:40

    Correct. Event handling is done via naming convention in VB6/VBA.
    The name can be the name of the control itlsef, or it can be a variable declared WithEvents. By assigning this variable a different reference, you start receiving events from that new object. This can be seen as dynamical subscribing.

    However, certain environments can provide additional means. For example, in Excel some placeable objects have hidden properties, such as Button.OnAction. You can assign a name of a macro to this property (as a string), and it will be called on button press.

    0 讨论(0)
提交回复
热议问题