简体   繁体   English

如何使用 VBA 在 SharePoint 中获取文件的上次修改日期?

[英]How will I get the last modified date of a file in a SharePoint using VBA?

I would like to seek help regarding on getting the last modified date of a file in a Sharepoint.我想寻求有关获取 Sharepoint 中文件的最后修改日期的帮助。 What VBA code/command will I use in order to execute it.我将使用什么 VBA 代码/命令来执行它。 I would like to show this "Last Modified Date" of the file in a MsgBox when a command button is clicked.单击命令按钮时,我想在 MsgBox 中显示文件的“上次修改日期”。

Your prompt response is very much appreciated.非常感谢您的及时回复。

This one had me scratching my head for a bit too...这个也让我摸不着头脑...

Make sure to add "@ssl" following the root URL eg确保在根 URL 后添加“@ssl”,例如

FileDateTime("\\\\site.com@ssl\\file.xlsx") FileDateTime("\\\\site.com@ssl\\file.xlsx")

You can use您可以使用

FileDateTime ( file_path )

to get the date and time of when a file was created or last modified.获取文件创建或上次修改的日期和时间。

For more information please visit the below link..欲了解更多信息,请访问以下链接..

VBA Help VBA 帮助

I've been trying to figure this out for a while and I stumbled upon something in another line of inquiry that led me to a solution.我一直在尝试解决这个问题,并且在另一条查询线中偶然发现了一些东西,这让我找到了解决方案。

In your VBA window, go to Tools -> References, and then scroll down and check the box next to "Microsoft Scripting Runtime".在您的 VBA 窗口中,转到“工具”->“参考”,然后向下滚动并选中“Microsoft Scripting Runtime”旁边的框。

Then when you specify your link it's going to read like this:然后,当您指定链接时,它将如下所示:

FileDateTime("//site.com/page/file.xlsx "). FileDateTime("//site.com/page/file.xlsx ").

No "http:" Once I did that, it worked like a charm.没有“http:”一旦我这样做了,它就像一个魅力。

Sub TestWhen()

    SPFilePath = "http://teams.MyCompany.com/sites/PATH/PATH/Fulfillment/Forms/AllItems.aspx"
    SPFileName = "2021_MyFileName.xlsx"

    MsgBox SPFileName  & " last modified on" & SPLastModified(SPFilePath, SPFileName)

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.

相关问题 如何使用 VBA 从 Sharepoint 获取 Excel 文件的上次修改日期? - How to Get Last Modified Date of excel file from Sharepoint using VBA? VBA-Office 365 / SharePoint-如何获取Sharepoint上文件的最后修改日期? - VBA - Office 365/SharePoint - How to get last modified date of file on Sharepoint? 如何在Excel 2010中使用VBA在目录中获取最后修改的文件 - How to get the last modified file in a directory using VBA in Excel 2010 Excel VBA使用FileSystemObject列出文件的最后修改日期 - Excel VBA using FileSystemObject to list file last date modified VBA - 如何在 Excel 2010 的目录中获取最后修改的文件或文件夹 - VBA - How to get the last modified file or folder in a directory in Excel 2010 VBA Outlook - 使用 MAPI 获取“最后修改者” - VBA Outlook - Get “last modified by” using MAPI Excel VBA通​​过多个文件扩展名和上次修改日期获取文件列表 - Excel VBA to get a file list by multiple file extensions and last modified date 如何使用VBA在SharePoint中打开文件夹的最后一个文件? - How to open the last file of a folder in a SharePoint using VBA? Powerpoint宏获取文件的最后修改日期 - Powerpoint macro to get the last modified date of a file 获取文件excel的最后修改日期 - Get last modified date of file excel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM