Chapter Summary

When you change the content you select in a document window, you can use the selection change event in Word, Excel, and PowerPoint to update custom menu commands and toolbar buttons. This is similar to how built-in commands and buttons are updated each time the selection changes. The Bold button on the Formatting toolbar, for example, is a command that is updated based on whether the selected text is bold or not.

You also can use the WindowBeforeDoubleClick and WindowBeforeRightClick events in Word and PowerPoint, or the SheetBeforeDoubleClick and SheetBeforeRightClick events in Excel, to cancel built-in behavior such as displaying a dialog box or shortcut menu. By canceling the built-in behavior, you can display a custom dialog box or a shortcut menu, or change the double-click or right-click behavior to a specific action that's dependent on what's clicked. Finally, by using the WindowActivate and WindowDeactivate events in combination with events such as the document Open and document Close event, you can develop programs that mimic built-in functionality, such as the Window menus in Word, Excel, and PowerPoint.