Weebie has asked for the wisdom of the Perl Monks concerning the following question:

I'm converting some old VBA code to Perl. The app sequentially opens, grabs key data, and closes a collection of some 2000 shared Excel workbooks. The data is written to a single "summary" workbook/sheet. I have most everything working but want to add the date, time and user stamps for the "last update" done on each workbook. I've tried everything I can think of to extract the update date/time/user data. I cannot find any Perl OLE methods for Excel update tracking. I've also tried a VBA module and then a macro in Excel to evoke update tracking "to another worksheet" where I can extract the data. But MS security patches have thwarted my efforts as a shared workbook can no longer have modules nor macros. Any ideas about how to do this through Perl OLE or otherwise?
  • Comment on Excel - Detecting Date/Time and User Stamps for last update.

Replies are listed 'Best First'.
Re: Excel - Detecting Date/Time and User Stamps for last update.
by Util (Priest) on Jun 09, 2007 at 00:39 UTC

    I don't know how to get the user info, but the time of last modification should be the time of last file write, unless the spreadsheet is currently open. So, instead of asking Excel, just ask the file system by using stat:

    $ touch foo.txt $ perl -wle 'print scalar localtime( ( stat "foo.txt" )[9] )' Fri Jun 8 19:38:29 2007

      Or, since we're talking MS here, use double quotes outside and singlequote inside since no interpolation is required. Otherwise cmd will complain about a missing terminator.
      >perl -wle "print scalar localtime( ( stat 'blossomshots_LJW.txt' )[9] + );"

      Output:
      Fri Jun 8 20:42:08 2007