How to: Display a Dialog Box to Open Excel Files
The following code prompts users to open a new workbook in Microsoft Office Excel. It sets properties to allow multi-selection, clears the list of available filters, and adds two new filters. The code then calls the Execute method of the FileDialog object to open the requested files.
Applies to: The information in this topic applies to document-level projects and application-level projects for Excel 2007 and Excel 2010. For more information, see Features Available by Office Application and Project Type.
Example
With Me.Application.FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen)
.AllowMultiSelect = True
.Filters.Clear()
.Filters.Add("Excel Files", "*.xls;*.xlw")
.Filters.Add("All Files", "*.*")
If .Show = True Then
.Execute()
End If
End With
Microsoft.Office.Core.FileDialog fd =
this.Application.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen);
fd.AllowMultiSelect = true;
fd.Filters.Clear();
fd.Filters.Add("Excel Files", "*.xls;*.xlw", missing);
fd.Filters.Add("All Files", "*.*", missing);
if (fd.Show() != 0)
{
fd.Execute();
}
See Also
Tasks
How to: List Recently Used Workbook Files