使用VBA将XMLstring布局导入Excel

我试图拉下面的查询的结果,但是当它到达XMLstring[处理数据]时,它不能在Excel中显示结果。 请有人协助? 谢谢

Public Sub Load_Error() Dim ADOC As New ADODB.Connection Dim SQL1 As String Dim rst1 As New ADODB.Recordset Dim i As Integer Dim r As Integer '#### Server Information Server_Name = "A" Database_Name = "B" '#### Server Connection is opened Worksheets("Load Errors").Activate r = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row Range(Cells(1, 1), Cells(r, 6)).ClearContents ADOC.Open "Provider=MSDASQL.1;DRIVER=SQL Server;SERVER=" & Server_Name & ";DATABASE=" & Database_Name & ";Trusted_Connection=Yes" SQL1 = "SELECT [CreatedDate],[RecordStatus],[Comment], CONVERT(varchar(max),[ProcessedData]) as [Error Message], [DataExceptionID], [SessionID] " & _ " FROM [C].[dbo].[D](nolock) " & _ " where CreatedDate >= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) and comment not in ('FrontierPositionRecon Load Errors','Errors', 'MCAP load errors') " & _ " order by createddate asc " ADOC.CommandTimeout = 600 Set rst1 = ADOC.Execute(SQL1) ActiveSheet.Cells(2, 1).CopyFromRecordset rst1 For i = 0 To rst1.Fields.Count - 1 ActiveSheet.Cells(1, i + 1).Value = rst1.Fields(i).Name Next Set rst1 = Nothing Set ADOC = Nothing End Sub 

不知道为什么,但如果你更换

设置rst1 = ADOC.Execute(SQL1)

rst1.打开SQL1,ADOC,adOpenStatic

有用。