Name
Application.GetOpenFilename([FileFilter
], [FilterIndex
], [Title
], [ButtonText
], [MultiSelect
])
Synopsis
Displays the Open File dialog box and returns a filename or False if no file is selected. Does not open the file.
Argument |
Setting |
---|---|
|
A filter to use in the drop-down list on the dialog box. Each filter is a pair separated by a comma: |
|
The index of the filter to display initially. |
|
The caption for the dialog box. Default is Open. |
|
(Macintosh only.) The caption to show on the action button. Default is Open. |
|
True allows the user to select multiple files. |
The following code displays the File Open dialog box for web file types; if the user selects a file, the code opens the file in Notepad:
Sub TestGetOpen( ) Dim fname As String, fltr As String fltr = "Web page (*.htm),*.htm,XML data (*.xml),*.xml," & _ "XML Style Sheet (*.xsl),*.xsl" fname = Application.GetOpenFilename(fltr, _ 1, "Open web file", , False) If fname <> "False" Then _ Shell "Notepad.exe " & fname End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.