You can use the SaveObject macro action to save either a specified Access object or the active object if none is specified. You can also save the active object with a new name in some cases (this functions the same as the Save As command on the Quick Access Toolbar).
Note: Beginning in Access 2010, the Save macro action was renamed to SaveObject.
Note: This action will not be allowed if the database is not trusted.
Setting
The SaveObject action has the following arguments.
Action argument | Description |
Object Type | The type of object you want to save. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the macro design window. To select the active object, leave this argument blank. If you select an object type in this argument, you must select an existing object's name in the Object Name argument. |
Object Name | The name of the object to be saved. The Object 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, you can leave this argument blank to save the active object, or, in some cases, enter a new name in this argument to save the active object with this name. If you enter a new name, the name must follow the standard naming conventions for Access objects. |
Remarks
The SaveObject macro action works on all database objects that the user can explicitly open and save. The specified object must be open for the SaveObject action to have any effect on the object. This action has the same effect as selecting an object and then saving it by clicking Save on the Quick Access Toolbar. Leaving the Object Type argument blank and entering a new name in the Object Name argument has the same effect as clicking Save As on the Quick Access Toolbar, and entering a new name for the active object. Using the SaveObject macro action enables you to specify an object to save and to perform a Save As command from a macro.
Note: You can't use the SaveObject macro action to save any of the following with a new name:
-
A form in Form view or Datasheet view.
-
A report in Print Preview.
-
A module.
-
A server view in Datasheet view or Print Preview.
-
A data access page in Page view.
-
A table in Datasheet view or Print Preview.
-
A query in Datasheet view or Print Preview.
-
A stored procedure in Datasheet view or Print Preview.
The SaveObject macro action, whether it's carried out in a macro run in the current database or in a library database, always saves the specified object or the active object in the database in which the object was created.
If you save the active object with a new name, but the name is the same as the name of an existing object of this type, a dialog box asks if you want to overwrite the existing object. If you've set the Warnings On argument of the SetWarnings macro action to No, the dialog box isn't displayed and the old object is automatically overwritten.
To run the SaveObject action in a Visual Basic for Applications (VBA) module, use the Save method of the DoCmd object.
No comments:
Post a Comment