Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Evaluate File for Last Updated Date

I want to have my macro code determine the date a file was last updated and
then from there, decide whether or not to open it. What I don't know is how
to access the file's property that returns that date it was updated. If I
could just use an "If" statement to say something like this, in principle:

If Filename.DateUpdated = Today() - 1 Then
Workbooks.Open Filename
End If

The goal is to only open files that have been updated within the last two
days. Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Evaluate File for Last Updated Date

Using document properties.

IF Filename.BuiltinDocumentProperties("Last Save Time") etc.


Gord Dibben MS Excel MVP

On Wed, 18 Nov 2009 13:54:05 -0800, jb_tenor1
wrote:

I want to have my macro code determine the date a file was last updated and
then from there, decide whether or not to open it. What I don't know is how
to access the file's property that returns that date it was updated. If I
could just use an "If" statement to say something like this, in principle:

If Filename.DateUpdated = Today() - 1 Then
Workbooks.Open Filename
End If

The goal is to only open files that have been updated within the last two
days. Is this possible?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Evaluate File for Last Updated Date

This should get you started

Option Explicit

Sub Test()
Dim FSO As Object
Dim RootFolder As Object
Dim myFolder As String
Dim File As Object

'define myFolder here

myFolder = "C:" 'Enter what you want
'Create FileSystemObject object
Set FSO = CreateObject("Scripting.FileSystemObject")

'Test if the folder exist and set RootFolder
If FSO.FolderExists(myFolder) = False Then
MsgBox myFolder & " doesn't exist"
Exit Sub
End If
Set RootFolder = FSO.GetFolder(myFolder)

For Each File In RootFolder.Files
Debug.Print File.Name, File.datelastmodified, File.datelastaccessed

Next File

Set FSO = Nothing

End Sub

IIRC, the BuiltInDocumentProperties can only be accessed once the file is
opened.

--
HTH,

Barb Reinhardt



"jb_tenor1" wrote:

I want to have my macro code determine the date a file was last updated and
then from there, decide whether or not to open it. What I don't know is how
to access the file's property that returns that date it was updated. If I
could just use an "If" statement to say something like this, in principle:

If Filename.DateUpdated = Today() - 1 Then
Workbooks.Open Filename
End If

The goal is to only open files that have been updated within the last two
days. Is this possible?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Evaluate Date for 21st birthday Karalee Excel Discussion (Misc queries) 2 October 31st 08 05:57 PM
date last updated hoyt New Users to Excel 1 December 19th 06 02:21 PM
Date last saved/updated Hal Excel Programming 2 May 22nd 06 08:28 PM
How many copies of a file can be updated by the "File/Save" comma. Dale New Users to Excel 1 May 2nd 05 02:34 AM
How do I keep the date from being updated every day JDP Excel Discussion (Misc queries) 3 December 23rd 04 07:53 PM


All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"