This documentation is archived and is not being maintained.

Rename Macro Action

Office 2007

You can use the Rename action to rename a specified database object.

 Note   This action will not be allowed if the database is not trusted. For more information about enabling macros, see the links in the See Also section of this article.


The Rename action has the following arguments.

Action argumentDescription
New NameA new name for the database object. Enter the object name in the New Name box in the Action Arguments section of the Macro Builder pane. This is a required argument.
Object TypeThe type of object you want to rename. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function. To rename the object selected in the Navigation Pane, leave this argument blank.
Old NameThe name of the object to be renamed. The Old Name box shows all objects in the database of the type selected by the Object Type argument. If you leave the Object Type argument blank, leave this argument blank also.

 Note   If you run a macro containing the Rename action in a library database, Microsoft Office Access 2007 first looks for the object with this name in the library database, and then in the current database.


The new name of the database object must follow the standard naming conventions for Access objects.

You can't rename an open object.

If you leave the Object Type and Old Name arguments blank, Access renames the object selected in the Navigation Pane. To select an object in the Navigation Pane, you can use the SelectObject action with the In Navigation Pane argument set to Yes.

You can also rename an object by right-clicking it in the Navigation Pane, clicking Rename, and entering a new name. With the Rename action, you don't have to select the object first in the Navigation Pane, and you don't have to stop the macro to enter the new name.

This action differs from the CopyObject action, which creates a copy of the object under a new name.

To run the Rename action in a Visual Basic for Applications (VBA) module, use the Rename method of the DoCmd object.

See Also
  • Enable or disable macros in Office documents