Sub FileModifiedTime()
Dim fso As Object
Dim fol As Object
Dim fil As Object
Dim timePoint As String
timePoint = InputBox("时间(格式:2020-4-16 20:00):")
If timePoint = "" Then
Exit Sub
End If
Dim timeStruct As Date
If IsDate(timePoint) Then
timeStruct = CDate(timePoint)
Else
Exit Sub
End If
Dim newPath As String
newPath = InputBox("请输入文件夹路径(格式:C:\Users\albert\Desktop\dir):")
Set fso = CreateObject("Scripting.filesystemobject")
Set fol = fso.GetFolder(ActiveDocument.Path)
For Each fil In fol.Files
If InStr(1, fil.Path, "$") > 0 Then
ElseIf InStr(1, fil.Path, ".doc") > 0 Then
If DateDiff("s", fil.DateLastModified, timeStruct) > 0 Or DateDiff("s", fil.DateCreated, timeStruct) > 0 Then 'fil.DateCreated, fil.DateLastAccessed
MsgBox fil.Name & " 修改或创建时间较早"
Else
MsgBox fil.Name & " 修改或创建时间较晚"
Documents.Open (fil.Path)
ActiveDocument.SaveAs2 (newPath & "\" & fil.Name)
ActiveDocument.Close
End If
End If
Next fil
End Sub