Can I retrieve ‘Date Modified’ from a CSV file???

Rags

Board Regular
Joined
Oct 25, 2006
Messages
202
Hi

Is there any way to retrieve the ‘Date Modified’ from a CSV file? As far as I know this is not stored in such a file but the information is retained in Windows Explorer. Can I somehow access it from Excel and place it in a cell or assign to a variable?

Thanks for any help.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Try this:
Code:
Sub ModifiedDate()
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(“C:/MyFile.csv”)
MsgBox f.DateLastModified
End Sub
Change the file path as appropriate.
 
Upvote 0

Rags

Board Regular
Joined
Oct 25, 2006
Messages
202
Thanks, that's really good.

Is there any way to format the date to: 22 August 2007 09:12:16
 
Upvote 0

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Perhaps like this:
Code:
Sub ModifiedDate()
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("C:\MyFile.csv")
Range("A1") = f.DateLastModified
Range("A1").NumberFormat = "dd mmmm yyyy hh:mm:ss"
End Sub
 
Upvote 0

Forum statistics

Threads
1,190,790
Messages
5,982,928
Members
439,807
Latest member
WXM86

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top