请检查下面的代码...这里我不想将转换后的 xml 代码保存在任何驱动器中,而是将转换后的文件的内容放入现有 excel 的下一张表中。
Sub GenerateXML()
'
' GenerateXML Macro
'
'
Sheets("Sheet2").Select
ActiveWorkbook.XmlMaps("result_Map").Export URL:="D:\temp3.xml"
Sheets.Add After:=Sheets(Sheets.Count)
With ActiveSheet.QueryTables.Add(Connection:="TEXT;D:\temp3.xml", Destination:=Range("$A$1"))
.Name = "temp3"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
' Kill "C:\temp.xml"
End Sub