使用 Excel VBA 删除或覆盖 SharePoint 列表?

Delete or Overwrite a SharePoint List using Excel VBA?

我可以使用 Excel VBA 和以下代码片段轻松创建 SharePoint 列表:

ActiveSheet.ListObjects("Table3").Publish Array( _
    "http://sitebuilder2.xyzcompany.com/operations", "test1"), False

但是,如果我使用相同的列表名称(“test1”),我会收到“运行-time error '3003': Application-defined or object-defined error”,因为列表已经存在。

是否有使用 Excel VBA 在 SharePoint 中覆盖列表(“test1”)或删除列表(“test1”)的直接方法,以便我可以更新整个列表而不提供新的列表名称?

我能够使用此代码同步到 SharePoint 列表。

Private Sub PublishRW()
  Dim listPoint As Range
  Dim fullServerName As String
  Dim retUrl As String
  
  Set listPoint = ActiveCell.ListObject.Range(1, 1)
  fullServerName = ServerName.Value & "_vti_bin"
  
  If ListDescription.Value = "" Then
    retUrl = ActiveCell.ListObject.Publish(Array(ServerName.Value, ListName.Value), False)
  Else
    retUrl = ActiveCell.ListObject.Publish(Array(ServerName.Value, ListName.Value, ListDescription.Value), False)
  End If
  
  If retUrl <> "" Then
    ActiveCell.ListObject.Delete
    ActiveSheet.ListObjects.Add xlSrcExternal, Array(fullServerName, ListName.Value), True, xlYes, listPoint
  Else
    MsgBox "There was an error during publish, please check the server name"
  End If
  Unload ExportRWList
End Sub