Now that you know how to use VBA statements to start a program and switch between applications, let's see how one application can communicate with another. The simplest way for an application to get control of another is by means of the SendKeys statement. This statement allows you to send a series of keystrokes to the active application window. You can send a key or a combination of keys and achieve the same result as if you worked directly in the active application window using the keyboard. The SendKeys statement looks as follows:
SendKeys string [, wait]
The required argument string is the key or key combination that you want to send to the active application. For example, to send a letter "f," use the following instruction:
To send the key combination Alt+f, use:
The percent sign (%) is the string used for the Alt key.
To send a combination of keys, such as Shift+Tab, use the following statement:
The plus sign (+) denotes the Shift key. To send other keys and combinations of keys, see the corresponding strings listed in Table 9-3.
Was this article helpful?