I am trying to build a macro to pull information from a SharePoint List. I'm using the following code and receiving an error:
Run-time error '1004' - Application-defined or object-defined error
Sub ImportSharePointList()
Dim objMyList As ListObject
Dim objWksheet As Worksheet
Dim strSPServer As String
Const SERVER As String = "Services/RemoteServices/Lists/"
Const LISTNAME As String = "{2B965E30-4D0D-4D81-BC27-2CDCEC10A17B}"
Const VIEWNAME As String = "{9C91F383-8C5C-40BD-81E2-7319DA1A6E61}"
strSPServer = "http://" & SERVER & "AllItems.aspx"
Set objWksheet = Worksheets.Add
Set objMyList = objWksheet.ListObjects.Add(xlSrcExternal, Array(strSPServer, LISTNAME, VIEWNAME), False, , Range("A1"))
End Sub
http://Services/RemoteServices/Lists//AllItems.aspx
? Notice the two/
slashes before 'AllItems'? – andrewRange("A1")
reference is causing a problem? It has to be the same worksheet that you're adding the ListObject to, but having said that, I thought adding a sheet would make it the active sheet anyway. I avoid unqualified references like this just to be sure. – andrew