title image


Smiley Re: Kann ich das GeändertDatum einer txt-Datei via VBA ändern?
Klar kann man! Den Code in ein leeres Modul kopieren und ausprobieren:Option Compare DatabaseOption ExplicitPrivate Type FILETIMElngLowDateTime As LonglngHighDateTime As LongEnd TypePrivate Type SYSTEMTIMEintYear As IntegerintMonth As IntegerintDayOfWeek As IntegerintDay As IntegerintHour As IntegerintMinute As IntegerintSecond As IntegerintMilliseconds As IntegerEnd TypePrivate Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As LongPrivate Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As LongPrivate Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As LongFunction setFileTime(strFileName As String, intYear As Integer, intMonth As Integer, intDayOfWeek As Integer, intDayOfMont As Integer, intHour As Integer, intMin As Integer, intSec As Integer, intMSec As Integer)Dim sysTime As SYSTEMTIME, flTime As FILETIME, lngFlHandle As LongsysTime.intYear = intYearsysTime.intMonth = intMonthsysTime.intDayOfWeek = intDayOfWeeksysTime.intDay = intDayOfMontsysTime.intHour = intHoursysTime.intMinute = intMinsysTime.intSecond = intSecsysTime.intMilliseconds = intMSecSystemTimeToFileTime sysTime, flTimeMsgBox Dir(strFileName, vbDirectory)If (Dir(strFileName) = "") Then MsgBox "Datei existiert nicht" & Chr(13) & "Funktion wird abgebrochen": Exit FunctionlngFlHandle = CreateFile(strFileName, &H40000000, &H1 Or &H2, ByVal 0&, 3, 0, 0)SetFileTime lngFlHandle, flTime, flTime, flTimeEnd FunctionFunction testSetFileTime()setFileTime "C:\Config.dos", 2000, 1, -1, 24, 23, 26, 0, 0End FunctiongreetingsStephan

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: