ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing 2 files on date/time stamp, and based time difference do a subroutine (https://www.excelbanter.com/excel-programming/398295-comparing-2-files-date-time-stamp-based-time-difference-do-subroutine.html)

[email protected]

Comparing 2 files on date/time stamp, and based time difference do a subroutine
 



Hello all,

I'm looking for a code which compares two given files. If the time
between the 2 files differ more than 10 minutes, a choise is given to
either open one file or the other.

such as:
N:\Shoes\Shoes.xls 2/14/2007 14:17
C:\Local\Shoes.xls 2/14/2007 16:22



It would be great if you could help me out here.
The code is needed in Excel-VBA 2002 SP2

Thanks! :-)


Robin Hammond[_3_]

Comparing 2 files on date/time stamp, and based time difference do a subroutine
 
This should get you started. It shows how to get the file time using the
windows scripting file system object.

Option Explicit

Sub Main()
EnumerateFileTimes ("C:\")
End Sub

Public Sub EnumerateFileTimes(strFolderPath As String)
Dim fsO As Object
Dim fsFolder As Object
Dim fsSubFolders As Object
Dim fsSub As Object
Dim fsFiles As Object
Dim fsFile As Object

Set fsO = CreateObject("Scripting.FileSystemObject")
Set fsFolder = fsO.GetFolder(strFolderPath)
Set fsSubFolders = fsFolder.Subfolders

For Each fsSub In fsSubFolders

Set fsFiles = fsSub.Files

For Each fsFile In fsFiles

Debug.Print "Folder: " & fsSub.Name, _
"File: " & fsFile.Name, _
"Date: " & FormatDateTime(fsFile.DateLastModified, vbShortDate),
_
"Time: " & FormatDateTime(fsFile.DateLastModified, vbShortTime)

Next

Next

End Sub


--
Robin Hammond
www.enhanceddatasystems.com


wrote in message
ups.com...



Hello all,

I'm looking for a code which compares two given files. If the time
between the 2 files differ more than 10 minutes, a choise is given to
either open one file or the other.

such as:
N:\Shoes\Shoes.xls 2/14/2007 14:17
C:\Local\Shoes.xls 2/14/2007 16:22



It would be great if you could help me out here.
The code is needed in Excel-VBA 2002 SP2

Thanks! :-)





All times are GMT +1. The time now is 04:54 AM.

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