Several File menu commands can be replaced by macros, enabling easy customization for content management systems. In all but one case, the macro can also use a COM equivalent method to call the default behavior, thereby allowing the macro to do something before and/or after the normal file operation.
The macros replace the entire action triggered by a particular menu item, its shortcut key, or its toolbar button. However, they are not called if the action in question is triggered in a different way. For example, if Save from the File menu is replaced by the File_Save macro, but the Close file operation triggers a `save', then the File_Save macro is not called. The On_Document_Save macro (see below) will be called in this situation.
Command | Macro | COM equivalent |
Open | File_Open | |
New (from menu) | File_Open_Template | Documents.OpenTemplate(); |
New.New (from toolbar) | File_New_Page | Documents.Add(false); |
Save | File_Save | ActiveDocument.Save(); |
Save As | File_SaveAs | ActiveDocument.SaveAs(); |
Save All | File_SaveAll | Documents.Save(); |
Close | File_Close | ActiveDocument.Close(); |
Close All | File_CloseAll | Documents.Close(); |
Note that the File_Open macro does not have an exact COM
equivalent (which would basically be `show the file open dialog'), but the method
Documents.Open can be used (for example, after showing a custom File
Open
dialog).
The special macro On_Document_Save is called
when a document is saved (by any means) under its current name. If the document is saved via the
Save
command (or an equivalent toolbar button or shortcut key) the macro
File_Save will also be called.
The special macro On_Document_SaveAs is
called when a document is saved (by any means) under a new name. If the document is saved via the
Save As...
command (or an equivalent toolbar button or shortcut key) the macro
File_SaveAs will also be called. Inside this macro,
ActiveDocument.FullName returns the new name of the document.
One of the special macros On_Before_Document_Save and On_Before_Document_SaveAs will be called if a save (or save as) is initiated through any means. The macro is called just before the file is saved, and allows you to make modifications to the file (such as updating an element with the document's modification date) before the save takes place.
Copyright © SoftQuad Software Inc. 1999