VBA 到 Sharepoint 如何添加人员或组

问题描述

我目前正在使用一个 VBA 脚本,它接收 excel 输入并将它们上传到 sharepoint。

我遇到的唯一问题是上传“人物”或“群组”时出现类型不匹配,可能是因为它试图获取链接

代码如下:

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
    Dim LastRow As Long,i As Long

    MysqL = "SELECT * FROM [TestingSharepoint];"

    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/TestingIPVABO Sharepoint;List={F1BDB92A-349A-4056-9EF4-F6C5AFC3CE9F};"
        .Open
    End With
    LastRow = Cells(Rows.Count,"A").End(xlUp).Row

    rst.Open MysqL,cnt,adOpenDynamic,adLockOptimistic
    
    Set Columntocheck = Worksheets("Audits_10d").Range("A1:A2000")

    For Counter = 11 To LastRow
       
       Valuetocheck = Sheets("Translation").Cells(Counter,3).Value

       If IsError(Application.Match(Valuetocheck,Columntocheck,0)) Then
            rst.AddNew
            rst.Fields("Task ID") = Sheets("Translation").Cells(Counter,3).Value
            rst.Fields("Seller ID") = Sheets("Translation").Cells(Counter,4).Value
            rst.Fields("Site") = Sheets("Translation").Cells(Counter,5).Value
            rst.Fields("Mktpl") = Sheets("Translation").Cells(Counter,6).Value
            rst.Fields("Country") = Sheets("Translation").Cells(Counter,7).Value
            rst.Fields("Inv_Date") = Sheets("Translation").Cells(Counter,8).Value
            rst.Fields("Associate_Login") = Sheets("Translation").Cells(Counter,9).Value
            rst.Fields("Manager_Login") = Sheets("Translation").Cells(Counter,10).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

因为输入看起来像这样:

enter image description here

有人知道如何修复它吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)