excel - 是否可以使用 VBA 将 Excel 列表的部分上传到 SharePoint 列表?
问题描述
我正在设置一个新的 SharePoint 列表,我想将前四/五列上传到 SharePoint(它们的名称和内容匹配),然后是第 12 列,因为它包含 SharePoint 的第五列。在您问我之前,我没有权限或授权来更改第 12 列的位置,因为该文档应该具有特定的格式。
作为 VBA 的新手,我不确定我是否了解如何连接到 SharePoint 网站,特别是这个列表,然后上传 Excel 数据。我以前手动上传过excel数据,但我想自动化这个过程,所以我可以运行一个宏来上传工作表中的项目(现在我只希望他们在以后可以整理重复项后成功上传)我'我不要求有文档的代码草稿我可以使用一些更熟悉 Excel-VBA/SharePoint 交互的人的帮助和指示。
我是 VBA 的新手,所以我打开了包含我的数据的工作簿(但不是工作表)(我选择使用打开文件方法,因为我不会是唯一使用这个宏的人,所以我决定让人们导航到他们的目录。
Sub UploadUntimed()
Dim my_FileName As Variant
my_FileName = Application.GetOpenFilename(FileFilter:="Excel Files,*.xl*;*.xm*")
If my_FileName <> False Then
Workbooks.Open Filename:=my_FileName
End If
End Sub
解决方案
请试试这个。
Private Sub CreateList()
Dim folder As folder
Dim f As File
Dim fs As New FileSystemObject
Dim RowCtr As Integer
RowCtr = 1
Set folder = fs.GetFolder("http://your_url_here/") '<=Variable Location
For Each f In folder.Files
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
Next f
End Sub
另外,试试这个。
Sub UpdateSpecificCells()
'If nobody has the file checked out
If Workbooks.CanCheckOut("http://your_url_here/ExcelList.xlsb") = True Then
Application.DisplayAlerts = False
'Open the file on the SharePoint server
Workbooks.Open Filename:="http://your_url_here/ExcelList.xlsb", UpdateLinks:=xlUpdateLinksNever
ActiveSheet.Cells(2, 7).Value = 100
ActiveSheet.Cells(3, 7).Value = 200
ActiveSheet.Cells(4, 7).Value = 300
'Close the workbook
Workbooks("ExcelList.xlsb").Save
Workbooks("ExcelList.xlsb").Close
End If
End Sub
推荐阅读
- python-3.x - Django模型根据输入日期排序结果
- ios - “控制台”显示变量的 nil 值,而“变量视图”显示相同的值
- javascript - 在页面上显示坐标的位置
- android - 删除后如何更新 RecyclerView 位置?
- javascript - Javascript中的Selenium,从下拉列表中选择元素
- java - 如何将 JCEF 与 Intellij 一起使用?
- c# - 在 xaml 代码中的 Listview 中绑定复选框的问题
- python - 如何在 if 语句中添加命令(tkinter)?
- flutter - 我想将常见的应用栏主题应用于颤振的应用栏
- java - 在java中从PDF中提取文本的最佳方法