适用于:Access 2013、Office 2013
可以使用 OpenVisualBasicModule 操作在指定的过程处打开指定的 Visual Basic for Applications (VBA) 模块。 此过程可以是 Sub 过程、Function 过程或事件过程。
注意
如果数据库不受信任,则不允许执行此操作。
Setting
OpenVisualBasicModule 操作具有下列参数。
操作参数 |
说明 |
|---|---|
模块名称 |
要打开的模块的名称。 如果要在数据库中的所有标准模块中搜索某个过程,并在该过程那里打开适当的模块,则可以将此参数留空。 如果在类库数据库中运行包含 OpenVisualBasicModule 操作的宏,Microsoft Access 将先在该类库数据库中查找具有此名称的模块,然后再在当前数据库中查找。 |
过程名称 |
要在打开模块后显示的过程的名称。 如果将此参数留空,则在打开模块后将显示其声明节。 |
注意
必须在“模块名称”或“过程名称”参数中输入一个有效的名称。
备注
You can use this action to open an event procedure by specifying the Module Name argument and the Procedure Name argument. For example, to open the Click event procedure of the PrintInvoice button on the form Orders, set the Module Name argument to Form.Orders and set the Procedure Name argument to PrintInvoice_Click. To view the event procedure for a form or report, the form or report must be open.
同样,要在类模块中打开某个过程,必须指定模块名称;不过,不需要打开类模块。
要打开私有过程,必须打开包含该过程的模块。
此操作等效于在导航窗格中右键单击模块,然后单击 "设计视图"。 通过此操作还可以指定过程名称以及在数据库中的标准模块中搜索过程。
提示
[!提示] 您可以在导航窗格中选择模块并将其拖至宏操作行。 这样会自动创建打开模块并显示其声明节的 OpenVisualBasicModule 操作。
若要在 VBA 模块中运行 OpenVisualBasicModule 操作,请使用 DoCmd 对象的 OpenModule 方法。