在Excel 2010中读取XML文件时出现问题

时间:2013-06-13 03:58:53

标签: xml excel-vba vba excel

我编写此代码以在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

1 个答案:

答案 0 :(得分:1)

与没有MSXML的VBA相比,Excel原生具有更好的XML处理能力。阅读XML Mapping功能。