从Sharepoint而不是公式中导入值

时间:2018-11-15 10:08:19

标签: excel vba excel-vba sharepoint

我正在尝试将数据从Sharepoint导入到Excel文件中。我编写了一个vba脚本,该脚本允许我导入列表的视图。我遇到的问题是某些列是作为公式而不是值导入的。由于视图中未包含公式中使用的某些列,因此计算出的列将返回为0。总之,是否有导入值而不是公式的方式,就像我直接从Sharepoint导出列表时那样。

Private Function GetListByName() As Boolean
    Const ListName As String = "ListName"
    Const ViewName As String = "ViewName"
    Dim tblRange As Range

    GetListByName = False

    On Error GoTo 0 'SharepointImportErr
    With Data
        .Cells.ClearContents

        .ListObjects.Add xlSrcExternal, _
        Array(Server & Customer & "/_vti_bin", "{" & ListGUID(ListName) & "}", "{" & ViewGUID(ListName, ViewName) & "}") _
        , False, , .Range("A1")

        With .ListObjects(1)
            Set tblRange = .Range
            .Unlink
            .Unlist
            tblRange.ClearFormats
        End With
    End With
    Set tblRange = Nothing

    GetListByName = True
    Application.StatusBar = False
    Exit Function
SharepointImportErr:
    Application.StatusBar = False
End Function

0 个答案:

没有答案