通过Excel VBA更新链接表(在Access 2003中)

我在Excel中有一些数据需要更新到MS访问中的链接表。 链接表连接到SharePoint站点。 我迄今为止的代码只适用于普通表格。 rs.Open在这种情况下返回未指定的错误。

Sub Button1_Click() On Error GoTo ExceptionHandle Dim cn As ADODB.Connection, rs As ADODB.Recordset ' connect to the Access database Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=D:\.....\db1.mdb;" ' open a recordset Set rs = New ADODB.Recordset 'ERROR rs.Open "LinkedTableName", cn, adOpenKeyset, adLockOptimistic, adCmdTable Range("B2").Activate ' row 1 contains column headings Do While Not IsEmpty(ActiveCell) s_title = ActiveCell.Offset.Value s_start_time = ActiveCell.Offset(0, 1).Value s_end_time = ActiveCell.Offset(0, 2).Value rs.Filter = "Title ='" & s_title & "'" If rs.EOF Then Debug.Print "No existing record - adding new..." rs.Filter = "" rs.AddNew Else Debug.Print "Existing record found..." End If rs("Title").Value = s_title rs("Start Time").Value = s_start_time rs("End Time").Value = s_end_time rs.Update Debug.Print "...record update complete." ActiveCell.Offset(1, 0).Activate ' next cell down Loop rs.Close Set rs = Nothing cn.Close Set cn = Nothing ExitProcedure: MsgBox "Update success" Exit Sub ExceptionHandle: MsgBox "Error:" & Err.Number & ": " & Err.Description Exit Sub End Sub