ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   access file based on last saved date/time (https://www.excelbanter.com/excel-programming/395834-access-file-based-last-saved-date-time.html)

SteveDB1

access file based on last saved date/time
 
Hello folks.
I'm trying to develop a multi-stage macro that will access a group of files,
and look at the last saved date. If that date is more recent than the file
the macro is calling from, I want to open, and then copy a portion of the
second file into the first.
We've purchased the WROX Excel 2007 VBA programmer's reference manual, but
I'm not able to readily identify the information I'm seeking to accomplish
the above.

So, at this point, I want to accomplish the following:
1- have the code to look at the save date in the properties of fileB.
2- if that date is more recent than the last save date of fileA, open fileB.

does anoyone know where I can look in the programmer's reference book to
learn more on how to perform this?
Or, how to do this?
Thank you.
Best.

joel

access file based on last saved date/time
 
Sub ShowFolderInfo()
Dim fs, myfolder, myfiles

Const MyPath = "c:\temp"



Set fs = CreateObject("Scripting.FileSystemObject")

Filename = UCase(ThisWorkbook.Name)
If Right(Filename, 3) < "XLS" Then
MsgBox ("File does not exist because Wrokbook was not saved")
End If

Set ThisFile = fs.getfile(ThisWorkbook.Name)
Thisdate = ThisFile.datelastmodified

Set myfolder = fs.GetFolder(MyPath)


For Each Filename In myfolder.Files
If UCase(Right(Filename.Name, 3)) = "XLS" Then

datemodified = Filename.datelastmodified

If datemodified Thisdate Then
'enter your code here
End If
End If
Next Filename

End Sub


"SteveDB1" wrote:

Hello folks.
I'm trying to develop a multi-stage macro that will access a group of files,
and look at the last saved date. If that date is more recent than the file
the macro is calling from, I want to open, and then copy a portion of the
second file into the first.
We've purchased the WROX Excel 2007 VBA programmer's reference manual, but
I'm not able to readily identify the information I'm seeking to accomplish
the above.

So, at this point, I want to accomplish the following:
1- have the code to look at the save date in the properties of fileB.
2- if that date is more recent than the last save date of fileA, open fileB.

does anoyone know where I can look in the programmer's reference book to
learn more on how to perform this?
Or, how to do this?
Thank you.
Best.



All times are GMT +1. The time now is 02:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com