Export data from SharePoint 2013 to Excel

Horus23

New Member
Joined
Jan 7, 2016
Messages
19
Hi Team,

I'm trying to export data from SP 2013 through VBA in Excel. I found this useful thread but since it's Dead, I'd to ask the question again.

http://www.mrexcel.com/forum/excel-...export-sharepoint-2010-list-excel-2010-a.html

This is the code by the user, but I want to know few things as not aware of them:

=> LISTNAME - how to get this information
=> VIEWNAME - how to get this information


Sub TestMacro()

Dim objMyList As ListObject
Dim objWksheet As Worksheet
Dim strSPServer As String

Const SERVER As String = "http://abcd/"
Const LISTNAME As String = "{A486016E-80B2-44C3-8B4A-8394574B9430}"
Const VIEWNAME As String = ""

' The SharePoint server URL pointing to the SharePoint list to import into Excel.

strSPServer = "http://" & SERVER & "/_vti_bin"

' Add a new worksheet to the active workbook.

Set objWksheet = Worksheets.Add

' Add a list range to the newly created worksheet and populated it with the data from the SharePoint list.

Set objMyList = objWksheet.ListObjects.Add(xlSrcExternal, _ Array(strSPServer, LISTNAME, VIEWNAME),
True, , Range("a2"))

Set objMyList = Nothing
Set objWksheet = Nothing

End Sub

If I know the above two information, hopefully I should be able to run the code.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Can someone help with this????
It's really easy...I found this info about doing it ;)

I think the site is very rudimentary but the blog post is excellent.. Too bad there is not more content..


"Sub MacroABCReport()‘Choose your variables
Dim objMyList As ListObject
Dim objWksheet As Worksheet
Dim strSPServer As String
Const SERVER As String = “somesite.sharepoint.com”
‘These GUIDs will come from your SharePoint site
‘You can deobfuscate list and view GUIDs at the following site
URL Decoder/Encoder
Const LISTNAME As String = “{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}”
Const VIEWNAME As String = “{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}”
strSPServer = “http://” & SERVER & “/_vti_bin”
‘Remove Old Data
Worksheets(“Data”).Select
Columns(“A:AG”).Select
‘Column selection will be dependent on SharePoint list data
‘if you select incorrect columns it will give error when refreshing the data
Selection.ClearContents
‘Import Data from SharePoint
‘Change value next to Range to begin insert of data
Set objWksheet = Worksheets(“Data”)
Set objMyList = objWksheet.ListObjects.Add(xlSrcExternal, Array(strSPServer, LISTNAME, VIEWNAME), False, , Range(“A2”))
End Sub
After you have created a blank workbook, place this script in the Visual Basic ..."


https://sharepointcatblog.wordpress.com/getting-sharepoint-data-through-vb-script-for-excel/
 
Upvote 0

Forum statistics

Threads
1,216,743
Messages
6,132,462
Members
449,729
Latest member
davelevnt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top