Visual Basic Extensibility Reference

Visual Studio 6.0

AfterWriteFile Event

See Also   Example   Applies To

Occurs after a file is written to disk.


Sub object_AfterWriteFile(vbproject As VBProject, filetype As vbext_FileType, filename As String, result As Integer)

The AfterWriteFile 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 to which the file was written.
filetype An enumerated value (vbext_FileType) specifying the type of file that was written, as listed in Settings.
filename A string expression specifying the name of the file that was written.
result A numeric expression that specifies the result of the write operation, as listed in 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 result are:

Value Description
0 Write was successful.
1 Write was canceled.
2 Write failed.


The AfterWriteFile event occurs when the binary data file associated with a component (such as an .Frx file) is saved for the first time, and 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.