Search code examples
excelvbaobjecteventscopy

Copying Event Triggers for Copied Control to New Multipage


I am creating some automation software for our company that dynamically creates pages on a Multipage depending on some data within a chosen excel file. I have controls set up on the object viewer with events to trigger (ie DblClick a ListBox or ComboBox).

This is my base UserForm with a Parent Multipage which contains a Listbox and another Multipage (child) that contains Frames with Labels, ComboBoxes, and Command Buttons.

How can I copy the events associated with an object to the new multipage?

I have started copying the existing objects already, but it's not complete.

I have been googling methods for copying events but the queries aren't relevant with certain KeyWords. I am looking into resources for Event Copying Now, but it seems to be limited. Seems the addressOf function on Copy event handler assignment to another instance is having issues when referencing another function.


Solution

  • I have copied event triggers by following some of the references for event handlers within classes.

    Created my own class to hold my ListBoxes and ComboBoxes and then allocated a dynamic array with the count of each needed. Associating the existing and new controls to the Class Array allowed the event handler to be used located within the Class.

    Works like a charm! Classes Rule!