我编写此代码以在Excel 2003中打开XSL文件,但此代码适用于2003而不是2010.我应该用与2010兼容的代码替换此代码?
以下是代码:
Sub test()
Dim fs As FileSearch
Dim i As Integer
Dim wbk As Workbook
Set fs = Application.FileSearch
With fs
.LookIn = ThisWorkbook.Path
.Filename = "*.xsl"
For i = 1 To .Execute()
Set wbk = Workbooks.Open(.FoundFiles(i))
wbkname = ActiveWorkbook.Name
' Selecting the name of site and the tenent operators
Range("A65536:Z65536").Select
Range(Selection, Selection.End(xlUp)).Select
Pr = Selection.Row
Range("A1" & ":" & "Z" & Pr).Select
Selection.Copy
Windows("1 macro.xls").Activate
Sheets("Sheet1").Select
Range("A65536").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Windows(wbkname).Activate
wbk.Close SaveChanges:=False
Next i
End With
End Sub