1. Press Alt + F11 keys to open Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste below code to the script.
VBA: Open all Excel files in a folder
Dim xStrPath As String
Dim xFileDialog As FileDialog
Dim xFile As String
On Error Resume Next
Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
xFileDialog.AllowMultiSelect = False
xFileDialog.Title = "Select a folder [Kutools for Excel]"
If xFileDialog.Show = -1 Then
xStrPath = xFileDialog.SelectedItems(1)
If xStrPath = "" Then Exit Sub
xFile = Dir(xStrPath & "\*.xlsx")
Do While xFile <> ""
Workbooks.Open xStrPath & "\" & xFile
xFile = Dir
3. Press F5 key, a dialog pops out for selecting a folder you want to open all workbooks within it. See screenshot:
4. Click OK, and all workbooks in the specific folder have been opened.
List all file names of one specific folder with Kutools for Excel
Except to open files in a folder, have you ever tried to list all file names of one specific folder? With Kutools for Excel’s Filename List utility, you can quickly list all types or one specific type of files in one folder.
1. Click Kutools Plus > Import & Export > Filename List. See screenshot:
2. In the Filename List dialog, select a folder you want to list files from, specify the file type you want to list, and then specify the unit of the file size as you need. If you want, you can create hyperlinks to the files names which will list. See screenshot:
3. Click Ok, and all files in the specific folder have been listed in a new sheet of the active workbook. See screenshot:
List All File Names Of A Folder
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.