0
使用下面的代碼導入使用Excel VBA從SharePoint數據,以下錯誤出現:如何將SharePoint列表導入Excel VBA?
運行時錯誤「1004」:
發生意外錯誤。更改您的數據無法保存
Sub ImportSharePointList()
Dim objMyList As ListObject
Dim objWksheet As Worksheet
Dim strSPServer As String
Const SERVER As String = "<server>:<Port>/Location/Lists"
Const LISTNAME As String = "{4e78c371-9ff0-410d-86a5-b78499091369}"
Const VIEWNAME As String = "{C3BD0F82-6BCD-45EF-B43E-DCFEA78067B0}"
strSPServer = "http://" & SERVER & "/_vti_bin"
Set objWksheet = Worksheets.Add
Set objMyList = objWksheet.ListObjects.Add(xlSrcExternal, _
Array(strSPServer, LISTNAME, VIEWNAME), False, xlYes, Range("A1"))
End Sub
從「所有網站內容」的URL獲取服務器字符串修復了問題。 – Chakri