RunMenuCommand 宏操作

适用于:Access 2013、Office 2013

可以使用 RunMenuCommand 操作运行内置的 Microsoft Access 命令。

Setting

RunMenuCommand 操作具有以下操作参数。

操作参数

说明

命令

要运行的命令的名称。 “命令”框按照字母顺序显示 Access 中可用的内置命令。 这是一个必选参数。

备注

可以使用 RunMenuCommand 操作运行自定义菜单栏、全局菜单栏、自定义快捷菜单或全局快捷菜单中的 Access 命令。

可以在具有条件表达式的宏内使用 RunMenuCommand 操作,以便根据某些条件运行命令。

注意

单击“文件”选项卡再单击“最近”会显示最近使用过的数据库。 可以单击这些数据库中的一个数据库,而不是单击“打开”。 These database items don't appear in the drop-down list box for the Command argument, and aren't available by using the RunMenuCommand action in a macro.

When you convert an Access database from a previous version of Access, some commands may no longer be available. 命令可能已被重命名、移到其他菜单或者不能再在 Access 中使用。 这类命令的 DoMenuItem 操作不能转换为 RunMenuCommand 操作。 打开宏时,Access 将为这类命令显示“命令”参数为空的 RunMenuCommand 操作。 You must edit the macro and enter a valid command argument, or delete the RunMenuCommand action.

若要在 Visual Basic for Applications (VBA) 模块中运行 RunMenuCommand 操作,请使用 Application 对象的 RunCommand 方法。 (这等效于 DoCmd 对象的 RunCommand 方法。)