Visual Basic for Applications/CommandButton Toggle

Summary
This VBA code module is made for Microsoft Excel but is easily adapted for use in other Office applications that can run VBA with user forms:
 * Two improved CommandButton_Click procedures are provided. They show better emphasis when buttons are prssed. CmmandButton1_Click has a toggle action, for example to set either one of two possible modes, and CommandButton2_Click performs the usual task of one function. In each case:
 * The user-set captions change in transition to reflect the current state of the buttons, for example Running etc.  This can be of interest in the toggle states or when a procedure takes a long time to run.
 * The button size is swelled about its center. This avoids enlargement from a fixed top-left point.   The amount of the increase can be set within the procedure.
 * The background and font color of the buttons are set in code, so are easily modified. Separate colors can be used for the two states.
 * The Me.Repaint lines ensure that the button formats update immediately. If they are not present the procedures will start, and perhaps end, before that was done.   Without Me.Repaint, but when DoEvents exists in the procedure-to-run, the repaint might still appear to work normally, until a procedure is run that does not require DoEvents.   For those who intend to study this point, it is shown up best in the CommandButton2_Click procedure.

The Code Module
Copy the UserForm_Initialize, CommandButton1_Click, and CommandButton2_Click procedures into the UserForm module of an Excel project. This can be achieved by first inserting a form called UserForm1, with one CommandButton called CommandButton1 and another CommandButton2. Double-click within the form in design mode to access its module. The Workbook_Open procedure goes into the ThisWorkbook module. Then, save the workbook, and run Workbook_Open (or re-open the workbook) to test the buttons on the form.

Modifications

 * 20 Jan 2019, added the previously omitted Me.Repaint code lines