适用于:Access 2013、Office 2013
![]() |
---|
避免使用 SendKeys 语句或带敏感或机密信息的 AutoKeys 宏。 恶意用户可能会拦截键击并损害您的计算机和数据的安全性。 |
可以使用 SendKeys 操作直接向 Microsoft Access 或基于 Windows 的活动应用程序发送键击。
注意
如果数据库不受信任,则不允许执行此操作。
Setting
SendKeys 操作具有下列参数。
操作参数 |
说明 |
---|---|
击 键 |
想让 Access 或其他应用程序处理的键击。 请在“宏生成器”窗格“操作参数”部分的“键击”框中输入键击。 最多可以键入 255 个字符。 这是一个必选参数。 |
Wait |
指定在处理完键击之前宏是否应该暂停。 请单击“是”(暂停)或“否”(不暂停)。 默认值为“否”。 |
备注
Access 处理通过 SendKeys 操作接收的键击,就好像您已经直接在 Access 窗口中键入它们一样。
要指定键击,请使用用于 SendKeys 语句的语法。
注意
An error can occur if the Keystrokes argument contains incorrect syntax, misspelled text, or other values that aren't appropriate for the window the keystrokes are sent to.
可以使用此操作在对话框中输入信息,尤其是在您不想中断宏的执行来手动响应对话框时。 有些 Access 操作(例如 PrintOut 和 FindRecord)会自动选择某些常用对话框中的选项。 可以使用 SendKeys 操作选择不常用的对话框中的选项。
注意
- Because the dialog box suspends the macro, you must put the SendKeys action before the action that causes the dialog box to open and set the Wait argument to No.
- 键击到达 Access 或其他应用程序的时间难以确定。 因此,在有其他方法(如 FindRecord 操作)可用来完成需要的任务时,建议您使用其他方法,而不要使用 SendKeys 操作来填写对话框中的选项。
如果希望向 Access 或其他基于 Windows 的应用程序发送 255 个以上字符,可以在宏中连续使用多个 SendKeys 操作。
使用 SendKeys 操作发送键击会触发相应的 KeyDown 、 KeyUp 和 KeyPress 事件。 发送非 ANSI 键击(如功能键)不会触发 KeyPress 事件。
此操作在 Visual Basic for Applications (VBA) 模块中不可用。 请改用 SendKeys 语句。