Flags

This property returns and sets the options for a Color, Font, Open, or Save As dialog box.

Syntax

object.Flags [= value]

Parameters

object
Object expression that evaluates to a CommonDialog control.
value
Constant or value that specifies the options for a Color, Font, Open, or Save As dialog box.

The following table shows the value settings for the Color dialog box.
Constant
Value
Description
cdlCCFullOpen &H2 Displays entire dialog box, including the Define Custom Colors command button
cdlCCPreventFullOpen &H4 Disables the Define Custom Colors command button and prevents the user from defining custom colors
cdlCCRGBInit &H1 Sets the initial color value for the dialog box

The following table shows the value settings for the Open and Save As dialog boxes.
Constant
Value
Description
cdlOFNCreatePrompt &H2000 Specifies that the dialog box prompts the user to create a file that does not currently exist. This flag automatically sets the cdlOFNPathMustExist and cdlOFNFileMustExist flags.
cdlOFNExtensionDifferent &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. You can check this flag value upon closing the dialog box.
cdlOFNFileMustExist &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 cdlOFNPathMustExist flag.
cdlOFNLongNames &H200000 Uses long file names.
cdlOFNNoChangeDir &H8 Forces the dialog box to set the current directory to what it was when the dialog box was opened.
cdlOFNNoDereferenceLinks &H100000 Does not dereference shell links, also known as shortcuts. If you choose a shell link, the shell dereferences the link by default.
cdlOFNNoLongNames &H40000 Does not use long file names.
cdlOFNOverwritePrompt &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.
cdlOFNPathMustExist &H800 Specifies that the user can enter only valid paths. If this flag is set and the user enters an invalid path, a warning message is displayed. You must enter the file name and path.

The following table shows the value settings for the Font dialog box.
Constant
Value
Description
cdlCFEffects &H100 Specifies that the dialog box enables strikethrough, underline, and color effects.
cdlCFForceFontExist &H10000 Specifies that an error message box is displayed if the user attempts to select a font or style that does not exist.
cdlCFLimitSize &H2000 Specifies that the dialog box selects only font sizes within the range specified by the Min and Max properties.
cdlCFScreenFonts &H1 Causes the dialog box to list only the screen fonts supported by the system.

Remarks

You also can define selected flags. Use the Const keyword in the Declarations section of the startup form to define the flags you want to use. The following code example shows how to use the Const keyword to define a flag.

Const Effects    = &H00000100&

You can set more than one flag for a dialog box using the Or operator. The followg code example shows how to set more than one flag.

CommonDialog1.Flags = &H10 Or &H200