1
如何將數據從記錄集填充到listobject中? 下面的代碼是不完全工作:vba listobject CopyFromRecordset
oCN.ConnectionString = "DRIVER={SQL Server};Server=SRVSQL;Database=TEST;"
oCN.Open
Dim sqlString As String
sqlString = "SELECT * FROM MYTABLE"
oRS.Open sqlString, oCN
With Feuil3.ListObjects("TableArticles")
If Not .DataBodyRange Is Nothing Then
.DataBodyRange.Delete
End If
' This make a 91 error
Call .DataBodyRange.CopyFromRecordset(oRS)
' This copy data into sheet, not into listobject
Call Feuil3.Range("A2").CopyFromRecordset(oRS)
End With