You can use Office.FileDialog to show dialog to choose file in excel vba.
Nội dung chính
Example
Following example show a dialog with file filters are "Excel 2007" and "All files", initial file name is current folder, type of dialog is "msoFileDialogFilePicker".
Public Sub selectInputFile() Dim fd As Office.FileDialog Set fd = Application.FileDialog(msoFileDialogFilePicker) With fd .AllowMultiSelect = False .InitialFileName = Application.ActiveWorkbook.path & "\" .Filters.Clear .Filters.Add "Excel 2007", "*.xlsx" .Filters.Add "All Files", "*.*" If .Show = True Then SelectedFile = .SelectedItems(1) End If End With End Sub
Output: