我编写了以下代码,不知道错在哪儿?望高手指点:
Private Sub CommandButton1_Click()
Dim wkb As Workbook
Dim sht As Sheets
Dim path As String
Dim filename
Dim a As Integer
Dim arry() As String
a = 0
Application.ScreenUpdating = False
path = "C:\Users\fanghao.luo\Desktop\TEST"
filename = Dir(path & "\" & "*.xlsx")
Do While filename <> ""
filename = Dir
If filename = "" Then
Exit Do
End If
a = a + 1
arry(a) = filename
Loop
For i = 1 To a
Workbooks.Open filename = path & arry(i)
Set sht = ActiveWorkbook.Sheets.COPY
ThisWorkbook.Sheets.Add sht
ActiveWorkbook.Close savechanges = False
Next
Application.ScreenUpdating = True
End Sub