ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I extract the last update date from a different excel file? (https://www.excelbanter.com/excel-programming/422710-how-do-i-extract-last-update-date-different-excel-file.html)

dennis

How do I extract the last update date from a different excel file?
 
I need to place the last update date of a data file that I use to extract
data to a different file. I need the formula to place this date in a cell at
the top of my working file. Thanks

Gary''s Student

How do I extract the last update date from a different excel file?
 
Here is the general idea:

Sub NeedADate()
Dim FSO As Scripting.FileSystemObject
Dim FileItem As Scripting.File
Set FSO = New Scripting.FileSystemObject
filespec = "C:\test\tulip.jpg"
Set FileItem = FSO.GetFile(filespec)
MsgBox (FileItem.DateLastModified)
End Sub

You must include a reference to Microsoft Scripting Runtime

You would use your real data file in place of the .jpg
and
to store the date, something like:

Range("A1").Value=FileItem.DateLastModified
--
Gary''s Student - gsnu200828


"Dennis" wrote:

I need to place the last update date of a data file that I use to extract
data to a different file. I need the formula to place this date in a cell at
the top of my working file. Thanks


Rick Rothstein

How do I extract the last update date from a different excel file?
 
You can use VB's FileTimeDate function to do that directly (without needing
any additional references)...

MsgBox FileDateTime("C:\test\tulip.jpg")

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Here is the general idea:

Sub NeedADate()
Dim FSO As Scripting.FileSystemObject
Dim FileItem As Scripting.File
Set FSO = New Scripting.FileSystemObject
filespec = "C:\test\tulip.jpg"
Set FileItem = FSO.GetFile(filespec)
MsgBox (FileItem.DateLastModified)
End Sub

You must include a reference to Microsoft Scripting Runtime

You would use your real data file in place of the .jpg
and
to store the date, something like:

Range("A1").Value=FileItem.DateLastModified
--
Gary''s Student - gsnu200828


"Dennis" wrote:

I need to place the last update date of a data file that I use to extract
data to a different file. I need the formula to place this date in a cell
at
the top of my working file. Thanks




All times are GMT +1. The time now is 12:31 AM.

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