Flags Property (File Dialogs)

ExampleexFlags_CDlgFil>Low

Applies To

Common dialog1H1HYJI.

Description

Sets the options for the Open and Save As dialog boxes.

Usage

[form.]CMDialog.Flags[ = flag ]

Remarks

The following constants are available for the Open and Save As dialog boxes:

Constant

Value

Description

 

OFN_ALLOWMULTISELECT

&H200&

Specifies that the File Name list box allows multiple selections.

The user can select more than one file at run time by pressing the Shift key and using the Up and Down Arrow keys to select the desired files. When this is done, the FileName property returns a string containing the names of all selected files. The names in the string are delimited by spaces.

OFN_CREATEPROMPT

&H2000&

Specifies that the dialog box should ask if the user wants to create a file that does not currently exist. This flag automatically sets the OFN_PATHMUSTEXIST and OFN_FILEMUSTEXIST flags.

OFN_EXTENSIONDIFFERENT

&H400&

Indicates that the extension of the returned file name is different from the extension specified by the DefaultExt property. This flag is not set if the DefaultExt property is Null, if the extensions match, or if the file has no extension. This flag value can be checked upon returning from the dialog box.

OFN_FILEMUSTEXIST

&H1000&

Specifies that the user can enter only names of existing files in the File Name text box. If this flag is set and the user enters an invalid file name, a warning is displayed. This flag automatically sets the OFN_PATHMUSTEXIST flag.

OFN_HIDEREADONLY

&H4&

Hides the Read Only check box.

OFN_NOCHANGEDIR

&H8&

Forces the dialog box to set the current directory to what it was when the dialog box was invoked.

OFN_NOREADONLYRETURN

&H8000&

Specifies that the returned file will not have the Read Only attribute set and will not be in a write-protected directory.

OFN_NOVALIDATE

&H100&

Specifies that the common dialog box allows invalid characters in the returned file name.

OFN_OVERWRITEPROMPT

&H2&

Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether to overwrite the file.

OFN_PATHMUSTEXIST

&H800&

Specifies that the user can enter only valid path names. If this flag is set and the user enters an invalid path name, a warning message is displayed.

OFN_READONLY

&H1&

Causes the Read Only check box to be initially checked when the dialog box is created. This flag also indicates the state of the Read Only check box when the dialog box is closed.

OFN_SHAREAWARE

&H4000&

Specifies that sharing violation errors will be ignored.

OFN_SHOWHELP

&H10&

Causes the dialog box to display the Help button.

 

These flags are defined in the Visual Basic CONSTANT.TXT file.

You can also define selected flags.  Use the Const keyword in the Declarations section of the startup form to define the flags you want to use.  For example:

Const OFN_READONLY  = &H00000001&
Const CF_EFFECTS    = &H00000100&
CMDialog1.Flags = &H10& Or &H200&

 

Adding the desired constant values produces the same results.  The following is equivalent to the preceding example:

CMDialog1.Flags = &H210&

Data Type

Long103F6YL