在SharePoint中,我手动创建了一个列表,并在其中的一列中命名为“ Impl。Date”,以匹配将要从中填充列表的excel工作表中的标题。
在SharePoint中,它看起来像:
当我查看记录集的字段名称时,“。”替换为“#”,如下所示:
我要替换现有SharePoint表的代码部分如下所示,并且该错误在nCounter循环的第5次迭代期间发生。这是Headers(nCounter)=“ Impl。Date”。
Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset
With cnt
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=0;RetrieveIds=Yes;DATABASE=http://my.company.com/SubSite/;LIST=" & GUID(Foldername) & ";"
.Open
End With
'set SQL string to filter the list to match what is to be done.
mySQL = "DELETE * FROM [" & SharepointListName & "];"
'activate SQL command
cnt.Execute mySQL, , adCmdText
mySQL = "SELECT * FROM [" & SharepointListName & "];"
rst.Open mySQL, cnt, adOpenDynamic, adLockOptimistic
For lCounter = Headerrow + 1 To LastRow
rst.AddNew
For nCounter = 1 To LastCol + 1
rst.Fields(Headers(nCounter)) = Sheets("Sheet1").Cells(lCounter, nCounter).Value
Next nCounter
' Select Case SharepointListName
' Case "NSP Index"
' rst.Fields("Region") = Sheets("Sheet1").Range("A" & lCounter).Text
' rst.Fields("NSP") = Sheets("Sheet1").Range("B" & lCounter).Text
' rst.Fields("Title") = Sheets("Sheet1").Range("C" & lconter).Text
' rst.Fields("Version") = Sheets("Sheet1").Range("D" & lconter).Text
' rst.Fields("Impl. Date") = Sheets("Sheet1").Range("E" & lconter).Text
' rst.Fields("Issue Date") = Sheets("Sheet1").Range("F" & lconter).Text
' rst.Fields("Link") = Sheets("Sheet1").Range("D" & lconter).Text
' Case "OPSD Index", "SSD Index", "MTOD Index"
'
' Case "OPSS Index", "SSP Index"
'
' End Select
' rst.Fields("FileLink") = filecaption & filelink
rst.Update
Next lCounter
我收到的错误框是:
现在,我假设原因是#不匹配导致“无法在与所请求的nam或ordinal相对应的集合中找到该项目”的原因。
我的假设我错了吗? 是否可以更改SharePoint字段名称以匹配Excel名称?我应该使用不同的方法?