![](/img/trans.png)
[英]How will I get the last modified date of a file in a SharePoint using VBA?
[英]How to Get Last Modified Date of excel file from Sharepoint using VBA?
我需要將excel文件的上次修改數據從共享點獲取到變量。
我在 sharepoint 中有 excel 文件,該文件將每周更新。 我只需要在變量中獲取 lats 修改日期即可繼續我的宏。 請幫忙。
提前致謝!!!
Public Function LastSaveTime() As String
Application.Volatile
LastSaveTime = ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function
這也應該適用於存儲在共享點庫中的工作簿 - 剛剛使用 SharePoint 2010 對其進行了測試
編輯以從 SharePoint 列表中獲取數據:
檢查此鏈接- 那里解釋了如何將列表數據讀入 excel。
通過此鏈接,您將能夠獲得 ListName 和 ViewName。
將這兩個組合在一起,最簡單的方法是為列表創建一個新視圖,並僅將更改列添加到視圖中 - 當數據已導入到 excel 時,您可以輕松讀取該數據並再次刪除添加的表。
希望這有助於讓您朝着正確的方向前進。 (已測試並使用 SP2010 列表)
Sub TestWhen()
SPFilePath = "http://teams.MyCompany.com/sites/PATH/PATH/Fulfillment/Forms/AllItems.aspx"
Debug.Print SPLastModified(SPFilePath, "2021_MyFileName.xlsx")
End Sub
Function SPLastModified(SPUrl As String, SPFName As String)
Dim ie As Object
Dim PagesHTML As String
Dim Dadate As String
Dim DaDateEnd As String
Dim arr() As String
arr = Split(OutString, " ")
Dim LastChange As Variant
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate SPUrl
Do Until .readyState = 4
DoEvents
Loop
Do While .busy: DoEvents: Loop
Do Until .readyState = 4
DoEvents
Loop
PagesHTML = ie.document.DocumentElement.outerHTML
End With
' Get to File
Dadate = InStr(PagesHTML, "FileLeafRef" & Chr(34) & ": " & Chr(34) & SPFName)
' Get to Modified Date
ModifiedText = "Modified" & Chr(34) & ": "
Dadate = Dadate + InStr(Mid(PagesHTML, Dadate), ModifiedText)
OutString = Mid(PagesHTML, Dadate + Len(ModifiedText), 27)
arr = Split(OutString, " ")
LastChange = arr(1) & " " & arr(2)
LastChange = arr(0) & "/" & Mid(arr(1), 6) & "/" & Mid(arr(2), 6, 4) & " " & LastChange
SPLastModified = LastChange
End Function
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.