Monday, 27 September 2010

Using VBA to get a File’s Last Modified Date

It is sometimes useful to know the date and time a file was last modified. this is particularly useful if you have a folder full of similar files and need to use the latest copy.

Today the code I’m going to share below enables you to pass a file address into a function which will return the date and time it was last saved. The example below passes a file address to the function, which returns the modified date, this is then displayed in a message box.

The function requires a reference to Microsoft Scripting Runtime within the VBE.