This documentation is archived and is not being maintained.

Visual Basic Extensibility Reference

Visual Studio 6.0

DoGetNewFileName Event

See Also   Example   Applies To

Occurs whenever a Save As operation is performed on any component or project, whether manually performed from the File menu, or programmatically performed.


Sub DoGetNewFileName(vbproject As VBProject, filetype As vbext_FileType, newname As String, oldname As String, canceldefault As Boolean)

The DoGetNewFileName event syntax has these parts:

Part Description
vbproject A VBProject object specifying the name of the project which will be written.
filetype An enumerated value (vbext_FileType) specifying the type of file to be written, as listed in Settings.
newname A string expression specifying the name of the new file. The file specification must be relative to the current LastUsedPath property or a fully qualified filename.
oldname A string expression specifying the old name of the file.
canceldefault A Boolean expression that determines the default Visual Basic action, as described 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 canceldefault are:

Setting Description
True Stops triggering this event for any subsequent add-ins connected to the FileControl object. If newname is a zero-length string ("") when canceldefault is set to True, the event is canceled; otherwise, the name entered in newname is used as the new filename.
False Continues triggering this event for subsequent add-ins connected to the FileControl object. If no add-in sets canceldefault to True, the Save File As or Make .Exe dialog box is displayed with the string you entered in newname selected.


If the canceldefault parameter is set to True, the Save File As dialog box is not displayed. If canceldefault is set to False, the Save File As dialog box displays. If more than one add-ins is connected, and canceldefault is set to True at any time during a Save As operation, the Save File As dialog box will not display for any of the add-ins until the next Save As operation is performed.

The newname argument is initially set to the same value as oldname, but any add-in that receives this event can change it. One way to do this is through a custom user interface where you obtain the new name of the file and set newname to the user's selection. However, if canceldefault is True (meaning that a previous add-in has set it to True), you shouldn't set newname again.

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.