ACC: Using SendKeys to Change Option MenusID: Q101074
|
Moderate: Requires basic macro, coding, and interoperability skills.
In a Microsoft Access macro, a SendKeys action must precede the DoMenuItem
action when you need to send keystrokes to a dialog window. For example,
when a DoMenuItem action opens the Print dialog to change a printing
parameter, the SendKeys keystrokes remain in the buffer and do not run if
the SendKeys action follows the DoMenuItem action.
Because opening a dialog window suspends a macro, you must execute the SendKeys action before the dialog opens. The following example demonstrates opening the Print dialog. Try running this macro from a button on a form.
Macro Name Action Comment
---------------------------------------------------------------
TestSendKeys SendKeys Store keystrokes for Print dialog
RunCommand Open Print dialog
TestSendKeys Actions
----------------------------
SendKeys
Keystrokes: %g1%t5{ENTER}
Wait: No
RunCommand
Command: Print
Macro Name Action Comment
---------------------------------------------------------------
TestSendKeys SendKeys Store keystrokes for Print dialog
DoMenuItem Open Print dialog
TestSendKeys Actions
----------------------------
SendKeys
Keystrokes: %g1%t5{ENTER}
Wait: No
DoMenuItem
Menu Bar: Form
Menu Name: File
Menu Command: Print
Macro Name Action Comment
---------------------------------------------------------------
TestSendKeys SendKeys Store keystrokes for Print dialog
DoMenuItem Open Print dialog
TestSendKeys Actions
----------------------------
SendKeys
Keystrokes: %p1%t5{ENTER}
Wait: No
DoMenuItem
Menu Bar: Form
Menu Name: File
Menu Command: Print
For more information about SendKeys, search the Help Index for "SendKeys
action."
For more information about SendKeys keystroke syntax, search the Help
Index for "SendKeys statement."
Keywords : kbusage McrActn
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 25, 1999