excel - 使用 Excel VBA 删除或覆盖 SharePoint 列表?
问题描述
我可以使用 Excel VBA 使用以下代码片段轻松添加创建 SharePoint 列表:
ActiveSheet.ListObjects("Table3").Publish Array( _
"http://sitebuilder2.xyzcompany.com/operations", "test1"), False
但是,如果我使用相同的列表名称(“test1”),我会收到“运行时错误'3003':应用程序定义或对象定义的错误”,因为该列表已经存在。
是否有一种直接的方法可以使用 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
推荐阅读
- c# - C# 数据表中某列的最大值
- outlook - Office365 在 C# 中读取收件箱电子邮件
- python - 使用 DataFrame.apply() 生成值时返回 Synset('') 包装器
- binary-tree - 二叉堆而不是二叉搜索树
- salesforce - 需要将值与 SFDC 中选择列表数据类型的自定义字段进行比较
- python - 熊猫:指数加权*滚动*相关性?
- python - 由另一个数据帧子集一个数据帧
- asp.net-core - Aurelia 授权 ASPNET Core
- python - Python:将值从更新的值附加到现有电子表格
- machine-learning - vgg16 微调狗猫在测试数据上失败