【问题标题】:Delete or Overwrite a SharePoint List using Excel VBA?使用 Excel VBA 删除或覆盖 SharePoint 列表?
【发布时间】:2020-12-15 20:22:24
【问题描述】:

我可以使用 Excel VBA 使用以下代码 sn-p 轻松添加创建 SharePoint 列表:

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

但是,如果我使用相同的列表名称(“test1”),我会收到“运行时错误'3003':应用程序定义或对象定义的错误”,因为该列表已经存在。

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

【问题讨论】:

    标签: excel vba sharepoint


    【解决方案1】:

    我能够使用此代码同步到 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 
    

    【讨论】:

    • 我真的很想试试这个,你能告诉我应该在哪里更改我的网站名称和列表详细信息吗?
    • 我不确定我是否理解您的问题。我首先创建了一个包含所需字段的 SharePoint 列表,然后将该模板导出到 Excel(“导出到 Excel”)。然后我开发了上面的 VBA 代码,将更新发布回 SharePoint 列表。
    猜你喜欢
    • 1970-01-01
    • 2021-09-03
    • 2017-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多