我有以下脚本从 Excel 复制数据并将其批量添加到共享点列表:
Sub AddItems()
'
' Requires a reference to "Microsoft ActiveX Data Object 6.0 Libray" to insert a record into a sharepoint list "AccessLog"
'
Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim mySQL As String
Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset
mySQL = "SELECT * FROM [Test];"
With cnt ' See https://www.connectionstrings.com/sharepoint/
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=0;RetrieveIds=Yes;DATABASE=https://share.amazon.com/sites/IPV;List={2B0ED605-AE50-4D39-A46E-77CC15D6F17E};"
.Open
End With
rst.Open mySQL, cnt, adOpenDynamic, adLockOptimistic
Set ColumnToCheck = Worksheets("Audits_10d").Range("A1:A2000")
For Counter = 16 To 24
ValueToCheck = Sheets("Audits").Cells(Counter, 28).Value
If IsError(Application.Match(ValueToCheck, ColumnToCheck, 0)) Then
rst.AddNew
rst.Fields("Task ID") = Sheets("Audits").Cells(Counter, 28).Value
rst.Fields("Seller ID") = Sheets("Audits").Cells(Counter, 5).Value
rst.Fields("Site") = Sheets("Audits").Cells(Counter, 30).Value
rst.Fields("Mktpl") = Sheets("Audits").Cells(Counter, 2).Value
rst.Fields("Country") = Sheets("Audits").Cells(Counter, 31).Value
rst.Fields("Inv_Date") = Sheets("Audits").Cells(Counter, 32).Value
rst.Fields("Associate_Login") = Sheets("Audits").Cells(Counter, 8).Value
rst.Fields("Manager_Login") = Sheets("Audits").Cells(Counter, 33).Value
rst.Fields("Associate Action") = Sheets("Audits").Cells(Counter, 10).Value
rst.Fields("Correct Associate Action") = Sheets("Audits").Cells(Counter, 11).Value
rst.Fields("SIV Action") = Sheets("Audits").Cells(Counter, 20).Value
rst.Fields("Correct SIV Action") = Sheets("Audits").Cells(Counter, 21).Value
rst.Fields("SIV RFI/RFD reason") = Sheets("Audits").Cells(Counter, 23).Value
rst.Fields("Data Correctly Captured").Value = Sheets("Audits").Cells(Counter, 26).Value
End If
Next Counter
rst.Update ' commit changes to SP list
If CBool(rst.State And adStateOpen) = True Then rst.Close
If CBool(cnt.State And adStateOpen) = True Then cnt.Close
End Sub
我刚刚遇到了一个小问题,因为共享点列表中的一些选项是一个带有是/否选项的复选框:
有什么办法可以与之交互吗?因为在我的 excel 中,我已经设置了是或否的选项,但似乎不起作用,所以我想它必须具有真假标准...
提前致谢。