Sub test()
Dim FName As String, FPath As String
Dim sheet As Worksheet
Dim FDialog As FileDialog
Application.ScreenUpdating = False
Set FDialog = Application.FileDialog(msoFileDialogFilePicker)
If FDialog.Show = -1 Then
FPath = FDialog.SelectedItems(1)
End If
'FName = Dir(FPath & "\*.xlsx*")
Do While FPath <> ""
Workbooks.Open Filename:=FPath, ReadOnly:=True
For Each sheet In ActiveWorkbook.Sheets
sheet.Copy After:=ThisWorkbook.Sheets(1)
Next sheet
Workbooks(FPath).Close
Loop
Sub test()
Dim FName As String, FPath As String
Dim sheet As Worksheet
Dim FDialog As FileDialog
Application.ScreenUpdating = False
Application.DisplayAlerts = False ' 關閉警告訊息
Set FDialog = Application.FileDialog(msoFileDialogFilePicker)
If FDialog.Show = -1 Then
FPath = FDialog.SelectedItems(1)
End If
Do While FPath <> ""
Set WB = Workbooks.Open(FPath)
For Each sheet In ActiveWorkbook.Sheets
sheet.Copy After:=ThisWorkbook.Sheets(1)
Next sheet
WB.Close
Loop
Sub test2()
Dim FName As String, FPath As String
Dim sheet As Worksheet
Dim FDialog As FileDialog
Application.ScreenUpdating = False
Application.DisplayAlerts = False ' 關閉警告訊息
Set FDialog = Application.FileDialog(msoFileDialogFilePicker)
If FDialog.Show = -1 Then
FPath = FDialog.SelectedItems(1)
End If
For x = 1 To FDialog.SelectedItems.Count
Set WB = Workbooks.Open(FPath)
For Each sheet In ActiveWorkbook.Sheets
sheet.Copy After:=ThisWorkbook.Sheets(1)
Next sheet
WB.Close
Next
For x = 1 To FDialog.SelectedItems.Count
FPath = FDialog.SelectedItems(x)
Set WB = Workbooks.Open(FPath)
For Each sheet In ActiveWorkbook.Sheets
sheet.Copy After:=ThisWorkbook.Sheets(1)
Next sheet
WB.Close
Next