ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing the Date/Time Stamp (https://www.excelbanter.com/excel-programming/419569-changing-date-time-stamp.html)

Robin Clay[_4_]

Changing the Date/Time Stamp
 
Now the clocks have gone back, and I forgot to change the time on my camera,
the time shown as the file creation date/time is now out by an hour.

How can I change this time in a VBA subroutine?

I have a routine wot does it, but this relies upon the presence and use of a
programme called "TOUCH.COM" that I don't have on this computer.

I had hoped that this line would work:-
Set f.DateLastModified = myTest2
....but it doesn't, so I resorted to creating a batch file.....

Here's the relevant part of the routine:-

Select Case DoWhat
Case Is = "ReName"
If NoDuplicate(LastRow, FirstRow, N, "B") _
And Len(Trim(Range("B" & N).Value)) 0 Then
OldName = myFolderName & Range("A" & N).Value
If Len(Ext(NewName)) = 0 Then _
NewName = NewName & "." & Ext(OldName)
Name OldName As NewName
Else
Range("B" & N).Font.ColorIndex = 3
Range("B" & N).Font.Bold = True
myText = "We have a duplicate name !"
End If
Case Is = "ReDate"
NewDate = Range("D" & N).Value
For M = 1 To .FoundFiles.Count
myTest1 = FileNameAndExt(.FoundFiles(M))
myTest2 = Worksheets("Sheet1").Range("A" & N).Value
If myTest1 = myTest2 Then
Set f = FSO.GetFile(.FoundFiles(M))
If Worksheets("Sheet1").Range("D" & N).Value < ""
Then
myTest1 = f.DateLastModified
myTest2 = Worksheets("Sheet1").Range("D" &
N).Value
myTest1 = "C:\Progra~1\Utilities\touch " & _
myShortPath(.FoundFiles(M)) & _
" /D:" & myWord(1, myTest2, " ")
& _
" /T:" & myWord(2, myTest2, " ")
' e.g. "C:\Program Files\Utilities\touch" 0891*.JPG
/D:26/02/2005 /T:15:04:00 /T:15:04:00
WriteThisToFile MyBatchFile, myTest1
'Set f.DateLastModified = myTest2
End If
M = .FoundFiles.Count
End If
Next M
Case Else
End Select



Regards

Robin


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

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