选择文件
Sub test() arr = pickfiles If arr(1) <> "None" Then For i = LBound(arr) To UBound(arr) Debug.Print arr(i) Next i End If End Sub Function pickfiles() As String() Dim arr() As String Dim i As Long With Application.FileDialog(msoFileDialogFilePicker) .InitialFileName = Application.ActiveWorkbook.Path .AllowMultiSelect = True .Filters.Clear .Filters.Add "Excel工作簿", "*.xls*" .Title = "请选取Excel工作簿" If .Show = -1 Then ReDim arr(1 To .SelectedItems.Count) For i = 1 To .SelectedItems.Count arr(i) = .SelectedItems(i) Next Else MsgBox "您未选择任何文件!", vbInformation, "Tips" ReDim arr(1 To 1) arr(1) = "None" End If End With pickfiles = arr End Function