How to: Display a Dialog Box to Open Excel Files

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.

Microsoft.Office.Core.FileDialog fd = 

fd.AllowMultiSelect = true; 
fd.Filters.Add("Excel Files", "*.xls;*.xlw", missing); 
fd.Filters.Add("All Files", "*.*", missing); 

if (fd.Show() != 0)

Community Additions

© 2016 Microsoft