Visual Basic Extensibility Reference
AfterCloseFile Event
See Also Example Applies To
Occurs after a project has been closed, either directly by the user, or by Visual Basic when the user quits the program.
Syntax
Subobject**_AfterCloseFile(vbprojectAs VBProject**, filetypeAs vbext_FileType, filenameAsString, wasdirty As Boolean)
The AfterCloseFile event syntax has these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
vbproject | A VBProject object specifying the name of the project in which the file was closed. |
filetype | An enumerated value (vbext_FileType) specifying the type of file that was closed, as listed in Settings. |
filename | A string expression specifying the name of the file that was closed. |
wasdirty | A Boolean expression that specifies whether changes were saved to a file prior to it being closed, as listed in Settings. |
Settings
The enumerated values for vbext_FileType are:
Constant | Value | Description |
vbext_ft_Form | 0 | File type is a form. |
vbext_ft_Module | 1 | File type is a basic module. |
vbext_ft_Class | 2 | File type is a class module. |
vbext_ft_Project | 3 | File type is a project. |
vbext_ft_Exe | 4 | File type is an executable file. |
vbext_ft_Res | 6 | File type is a resource file. |
vbext_ft_UserControl | 7 | File type is a User control. |
vbext_ft_PropertyPage | 8 | File type is a Property Page. |
vbext_ft_DocObject | 9 | File type is a User Document. |
vbext_ft_Binary | 10 | File type is a binary file. |
vbext_ft_GroupProject | 11 | File type is a group project. |
vbext_ft_Designer | 12 | File type is a designer object. |
The settings for wasdirty are:
Setting | Description |
True | The file was dirty when it was closed. (That is, the user elected to not save changes made to the file prior to closing it.) |
False | The file was not dirty when it was closed (That is, the user selected to save changes made to the file prior to closing it.) |
Remarks
This event can occur once for each add-in connected to the FileControl object in each project; once for each form, module, class, and control file, and once for the project file.
The AfterCloseFile event does not occur if the form is dirty and the user selects No on the Save changes to the following files dialog box. Also, this event does not occur for .Frx files when a project is closed. It occurs when the .Frm file is saved.
This event occurs in all add-ins that are connected to the FileControl object. The add-in cannot prevent the file from being written to disk because the operation is complete. However, you can use this event to perform other tasks, such as:
Log information about the event.
Update information about the file.
Back up the file.
Compare versions of the executable (.EXE) file.