Hi all,
I have a problem in importing a Sharepoint list to excel 2010 with vba.I googled for the code and I found something like this.
Private Sub Workbook_Open()
Dim objMyList As ListObject
Dim objWksheet As Worksheet
Dim strSPServer As String
Const SERVER As String = "https://****.com"
Const LISTNAME As String = "PrTracker"
Const VIEWNAME As String = "All Items"
' 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("temp")
' 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, , objWksheet.Range("a2"))
Set objMyList = Nothing
Set objWksheet = Nothing
End Sub
I am getting application defined error 1004.
would be grateful if someone can help me.
Tanks for reading!!
I have a problem in importing a Sharepoint list to excel 2010 with vba.I googled for the code and I found something like this.
Private Sub Workbook_Open()
Dim objMyList As ListObject
Dim objWksheet As Worksheet
Dim strSPServer As String
Const SERVER As String = "https://****.com"
Const LISTNAME As String = "PrTracker"
Const VIEWNAME As String = "All Items"
' 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("temp")
' 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, , objWksheet.Range("a2"))
Set objMyList = Nothing
Set objWksheet = Nothing
End Sub
I am getting application defined error 1004.
would be grateful if someone can help me.
Tanks for reading!!