简体   繁体   English

VBA将SharePoint项目数据导出到Excel电子表格

[英]VBA Export SharePoint Items Data to Excel Spreadsheet

Recently I am trying to export the data within each list item on SharePoint to Excel using VBA. 最近,我试图使用VBA将SharePoint上每个列表项中的数据导出到Excel。 Below is the list. 以下是列表。

在此处输入图片说明

And if you click on each one it looks like: 如果您单击每一个,它看起来像:

在此处输入图片说明

So the data I crossed out are the values that I want them to be exported to an Excel Spreadsheet. 因此,我划掉的数据就是我希望将它们导出到Excel电子表格中的值。

I know how to export the whole list of to excel, the code is: 我知道如何导出excel的整个列表,代码是:

Sub ImportSharePointData()

    Dim objMyList As ListObject
    Dim objWksheet As Worksheet
    Const SPServer As String = "http://ln-   sharepoint.XXXintra.net/XXX/XXX/XXX/_vti_bin"
    Const LISTNAME As String = "{06AAB69F-XXX-XXX-XXX-8F677FE38D76}"
    Const VIEWNAME As String = "Agreement"
    ActiveSheet.ListObjects.Add SourceType:=xlSrcExternal, Source:= _
    Array(SPServer, VIEWNAME, LISTNAME), LinkSource:=True, Destination:=Range("A1")

End Sub

Now I want data in each individual item in this list eg Item with ID 367, exporting the field of Counterparty Name, CSID etc to excel. 现在,我想要此列表中每个单独项目中的数据,例如ID为367的项目,将交易对手名称,CSID等字段导出为ex​​cel。

Also, it looks like these data are filled in by users into forms on SharePoint that are designed using InfoPath. 同样,看起来这些数据已由用户填充到使用InfoPath设计的SharePoint表单中。

Is there anyway that I can do this without using the designer level of access? 无论如何,我可以在不使用设计者访问权限的情况下做到这一点?

Thank you very much in advance for any solution or advice. 非常感谢您提供任何解决方案或建议。

As long as the desired fields on the InfoPath form are directly associated with SharePoint columns, the data will be available to display and export. 只要InfoPath表单上的所需字段直接与SharePoint列相关联,数据就可以显示和导出。

Notice that you specify which view you want when you export the list to Excel. 请注意,当您将列表导出到Excel时,您指定了所需的视图。

Const VIEWNAME As String = "Agreement"

With this in mind, simply create a new public view of the list that shows all the columns of data that you want to export. 考虑到这一点,只需为列表创建一个新的公共视图即可显示要导出的所有数据列。 Then export that list view instead. 然后导出该列表视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM