0

我目前正在将 Sharepoint 列表导出到 Excel 2013,但注意到每当我在模块顶部指定 Option Base 1 时,导出都会引发“下标超出范围”错误。当我删除 Option Base 1 时,宏名义上运行。我的猜测是,这可能与正在导入的列表的枚举和第 0 个元素未被识别有关。我的问题是:a) 有没有人知道为什么会发生这种情况,如果不是因为我猜到的原因?b) 如果有办法保留 Option Base 1 而不会在导入时引发错误?代码:

Option Base 1

Sub Sharepoint_Import()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim objMyList As ListObject
Dim objWksheet As Worksheet
Const SERVER As String = "https://xxxx/_vti_bin"

Const LISTNAME As String = "{xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"
Const VIEWNAME As String = "{xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"

Set objWksheet = ActiveWorkbook.Worksheets("Data")

'Clear older data on Sheet "Data"
objWksheet.UsedRange.ClearContents
objWksheet.UsedRange.ClearFormats

'Import data
Set objMyList = objWksheet.ListObjects.Add(xlSrcExternal, Array(SERVER, LISTNAME, VIEWNAME), True, , Range("A1"))

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
4

0 回答 0