Chapter 9

Retrieving and Setting Active Content

No matter how many documents you may have open, you can interact with only one at a time. That single document is referred to as the active document, and it's contained in the active window. In most cases, a current selection is within the active window. This selection can be anything from a range of text characters selected in Microsoft Word to a range of cells selected in Microsoft Excel to a set of shapes selected in Microsoft PowerPoint.

As you work with a Microsoft Office document, you use a number of menu and toolbar commands to operate on the active document, the active window, or the current selection (the selection in the active window). Commands on the File menu, like Save, Save As, Close, and Print, act on the active document that's displayed to the user. On the Edit menu, the Cut and Copy commands act on the current selection. On the Formatting toolbar, the Font drop-down list sets the font of the current text selection and the Bold button sets the text to bold.

A number of commands set the active document or selection. For example, the Window menu lists all the documents currently open. Each item you click on the Window menu becomes the active document. When you use the spelling checker or the Find and Replace functionality on a text string, the application scrolls and sets the selection to the text string that is to be corrected or replaced.

The majority of commands in the command bar set act on the current document or current selection. Similarly, you'll develop programs that need to retrieve, set, or act upon the active document or current selection. This chapter discusses the ways you use Word, Excel, PowerPoint, and Outlook to retrieve, set, and manipulate the active content.