0

I am trying to use VBA to create an Excel report to display the Last Modified date property value of all of the file paths names read from an input file. This is how I get the LastModified date:

Set fso = CreateObject("Scripting.FileSystemObject")
Set currentFile = fso.GetFile(inputFile)
Sheet.Cells(r, 2).Value = currentFile.DateLastModified '<<<Incorrect value

The value displayed for every file read is the current system time in each case. Windows Explorer shows me the correct Last Modified time. When I debug, I see that the DateLastModified property is in fact the same value the Excel report shows.

Why does the DateLastModified function not appear to work?

Not sure if this is related, but my PC does have the msvbvm60.dll VB runtime on it. Could it be a reguistration issue? I could not set a reference to scrrun.dll from a VB.NET project. I followed the instructions here: to create a new library from the scrrun.dll. It looks like it created a library dll with a different name, Scripting.dll, that I was able to reference. Not sure if any of this is related.

Community
  • 1
  • 1
Chad
  • 23,658
  • 51
  • 191
  • 321

2 Answers2

1

The DateLastModified property is Null when a file is created. Some processes will update the value when a file is closed, but many of them will not.

Philip Sheard
  • 5,789
  • 5
  • 27
  • 42
0

My apologies. It was a dumb coding bug. I was checking teh modified date on my input file, not on the path read from the file. Duh!

It's up to the community if this is worth not deleting.

Chad
  • 23,658
  • 51
  • 191
  • 321