Excel VBA Macro : Excel file versions
  • Run a macro to control versioning.Perhaps compares Excel work on a particular model with several people (want to know who modified the file)
  • FileSystemObject object by reference enlarge
  • You can not work with files in any installation with VBA features installed can access.
  • We can read, write, delete, etc., files and folders
  • We obtain information such as:
  • Creation date of an Excel file.
  • Date of last modification of an Excel file
  • Last access date to an Excel file
  • Imagine if you can also capture and record the user in a very hidden sheet each time you press the save button ...
    Son Goku
Sub Check_File()

On Error Resume Next
Dim o_file As Object, o_fso As Object, FullPath As String
Dim last_acces As String, last_change As String, date_creation As String

FullPath = ActiveWorkbook.FullName
Set o_fso = CreateObject("Scripting.FileSystemObject")
Set o_file = o_fso.GetFile(FullPath)
date_creation = o_file.DateCreated
last_change = o_file.DateLastModified
last_acces = o_file.DateLastAccessed

Range("C1") = "Heading"

 If Err.Number <> 424 Then
Range("C2") = "Date_creation: " & date_creation
Range("C3") = "Last_change: " & last_change
Range("C4") = "Last_acces: " & FormatDateTime(last_acces)

Range("C2") = "Date_creation: " & Err.Description
Range("C3") = "Last_acces: " & Err.Description
Range("C4") = "Last_acces: " & Err.Description
End If

Set fso = Nothing
Set archivo = Nothing

End Sub
Excel VBA Code - Preview