OPENFILENAME-type variables work with the two Windows file dialog box APIs, GetOpenFileName and GetSaveFileName.
This structure is used both to pass information to the function and to return data from it.
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustomFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As String
lpstrFileTitle As String
nMaxFileTitle As String
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
The size in bytes of the variable (use the Len() function).
The handle of the window opening the file dialog box.
If using a dialog box template, this is the handle to the memory block of the dialog box template to use. If using the default
dialog box, set to 0.
The entries in the File Type drop box. The format of the string is "name of file type" & vbNullChar & "mask" &
vbNullChar ... for as many types, where name of file type is the text that appears in the list and mask is the extension
mask. The string must end with a double vbNullChar.
Similar to lpstrFilter, but holds only one file type name/mask pair that specifies a user-defined file type. If unused, set to an
The size in bytes of the string contained in lpstrCustomFilter.
The number (#1, #2, etc.) of data type specified lpstrFilter should be the default one.
Set it as a series of blank spaces. Receives the complete path and filename of the file(s) the user selects. If multiple files are
selected, each filename is separated by vbNullChar, and the entire string will end with a double vbNullChar.
The length in characters of lpstrFile.
Very similar to lpstrFile, but only receives the filename of the selected file. If multiple files are selected, this is not set to any
The length in characters of lpstrFileTitle.
The default directory to look in.
The text that appears in the dialog box's title bar.
Zero or more of the following flags specifying how to create the file dialog box. Some of these flags will be set by the
function after the call to reflect the user's selections.
OFN_ALLOWMULTISELECT = &H200
Allow the user to select multiple files (Open File dialog box only).
OFN_CREATEPROMPT = &H2000
Prompt if a non-existing file is chosen.
OFN_ENABLEHOOK = &H20
Use the function specified by lpfnHook to process the dialog box's messages.
OFN_ENABLETEMPLATE = &H40
Use the dialog box template specifed by hInstance and lpTemplateName.
OFN_ENABLETEMPLATEHANDLE = &H80
Use the preloaded dialog box template specified by hInstance.
OFN_EXTENSIONDIFFERENT = &H400
The function sets this flag if the user selects a file with an extension different than the one specified by lpstrDefExt.
OFN_FILEMUSTEXIST = &H1000
Only allow the selection of existing files.
OFN_HIDEREADONLY = &H4
Hide the Open As Read Only check box (Open File dialog box only).
OFN_NOCHANGEDIR = &H8
Don't change Windows's current directory to match the one chosen in the dialog box.
OFN_NODEREFERENCELINKS = &H100000
If a shortcut file (.lnk or .pif) is chosen, return the shortcut file itself instead of the file or directory it points to.
OFN_NONETWORKBUTTON = &H20000
Hide and disable the Network button in the dialog box.
OFN_NOREADONLYRETURN = &H8000
The function sets this flag if the selected file is not read-only (Open File dialog box only).
OFN_NOVALIDATE = &H100
Don't check the filename for invalid characters.
OFN_OVERWRITEPROMPT = &H2
Prompt the user if the chosen file already exists (Save File dialog box only).
OFN_PATHMUSTEXIST = &H800
Only allow the selection of existing paths.
OFN_READONLY = &H1
Check the Open As Read Only box. This flag is set after the function call if the box is checked after the user clicks
OFN_SHAREAWARE = &H4000
Ignore any file sharing violations.
OFN_SHOWHELP = &H10
Show the Help button in the dialog box.
Receives the zero-based index specifying where in lpstrFile the pathname ends and the filename begins.
Receives the zero-based index specifying where in lpstrFile the file extension begins.
The default extension of a file (only for the Save dialog box). If a file is chosen with the *.* mask, the file gets this extension.
Don't include the period.
Information to pass to the hook function specified by lpfnHook whenever it is called.
Points to a hook function that processes the dialog box's messages. The function should return 0 to pass the message back
to the dialog box and 1 not to pass it. If not using a hook function, set to 0.
The name of the dialog box template specified by hInstance.
No Example Available