Hello twd000,
SubClassing is an advanced technique that allows you to redirect control or customize events. There are two parts to this approach. First is to create a Class or more simply a VBA object that responds to the same events as an existing VBA object. Secondly, this new object needs to be instantiated (created) so it will respond to the event before the original object does.
The code you posted is for the Class Module.
1) Insert a Class Module into your VBA Project
2) Copy the code into it
3) Change the Class name from Class1 to EventClassModule. This is the name VBA uses to create the object.
4) The class name appears in Name property of the Properties window. Press F4 to display the window.
Class Module Code
Creating the object is done in a Standard VBA module. This allows the new object to be accessible from any part of your project and remain in memory until the VBA project is terminated. Call or run InitApp when you are ready to have the events redirected.
Standard Module Code
Sincerely,
Leith Ross
Bookmarks