Adding VBA Code to an ActiveX Control

After you add controls and set properties, you can add VBA code to a module to determine how the controls respond to user actions. All controls have a predefined set of events. For example, a command button has a Click event that occurs when the user clicks the button. When you select a control in Design Mode and then click the View Code button, the Visual Basic Editor opens with a Code window, displaying the start of a procedure that runs when the event occurs. The top of the Code window displays the active object and event procedure. The Object list displays the ActiveX control, such as CommandButton1, and the Procedure list displays the trigger event, such as Click.

Add VBA Code to an ActiveX Control

Get Word 2013 on Demand now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.