2017-05-31 53 views
1

有人可以幫助我如何更改視圖在Excel中,它與Sharepoint中的列表連接?這是我的VBA代碼:更改鏈接的Excel中的視圖與SharePoint列表

Sub link_edit_Mode() 

Dim mySh As Worksheet 
Dim spSite As String 

Set mySh = Sheets("one") 

Dim src(0 To 1) As Variant 

    spSite = " url " 'site name 
    src(0) = spSite & "/_vti_bin" 
    src(1) = "{lists GUID}" 'GUID 

mySh.ListObjects.Add xlSrcExternal, src, True, xlYes, mySh.Range("A1") 

End Sub 

它的工作原理,但它給了我從SharePoint的表,它具有默認視圖,但我需要更改此視圖。

回答

0

你需要做的微小變化在你的代碼(見下文)

Sub link_edit_Mode() 

Dim mySh As Worksheet 
Dim spSite As String 

Set mySh = Sheets("one") 

Dim src(0 To 2) As Variant 

    spSite = " url " 'site name 
    src(0) = spSite & "/_vti_bin" 
    src(1) = "{lists GUID}" 'GUID 
    src(2) = "{view GUID}" 

mySh.ListObjects.Add xlSrcExternal, src, True, xlYes, mySh.Range("A1") 

End Sub 
相關問題