我编写了这段代码以在 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