LogPath = "C:\Users\Windows\Desktop"
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim dt, fn '定义两个变量用于在遍历时记录最新的创建时间和文件名
dt = "1990-1-1" '设定一个时间初始值用于后续比较
If FSO.FolderExists(LogPath) Then
Set Folder = FSO.GetFolder(LogPath)
For Each File In Folder.Files
If LCase(Right(File.Name, 3)) = "tif" Then '判断文件后缀
If DateDiff("s", dt, File.DateCreated) > 0 Then '比较创建时间
'间隔时间以秒(s)为单位,返回两个时间间隔的秒数
'若 dt > File.DateCreated,DateDiff返回负数
'若 dt < File.DateCreated,则更新dt和fn
dt = File.DateCreated
fn = File.Name
End If
End If
Next
Set Folder = Nothing
Else
'若文件夹路径不存在,给出错误提示并退出脚本运行
MsgBox "Folder " & LogPath & " not found!", vbExclamation
WScript.Quit
End If
'MsgBox fn '显示创建时间最新的文件名(不含路径),调试时可放开注释
'至此,得到文件名
我是从百度知道中的一个答案修改的,需要检索桌面上最新创建的.tif文件。现在已经检索出了最新tif的名字了。我想知道接下来加上什么语句能用quickmtf.exe这个程序打开这个检索出来的文件
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim dt, fn '定义两个变量用于在遍历时记录最新的创建时间和文件名
dt = "1990-1-1" '设定一个时间初始值用于后续比较
If FSO.FolderExists(LogPath) Then
Set Folder = FSO.GetFolder(LogPath)
For Each File In Folder.Files
If LCase(Right(File.Name, 3)) = "tif" Then '判断文件后缀
If DateDiff("s", dt, File.DateCreated) > 0 Then '比较创建时间
'间隔时间以秒(s)为单位,返回两个时间间隔的秒数
'若 dt > File.DateCreated,DateDiff返回负数
'若 dt < File.DateCreated,则更新dt和fn
dt = File.DateCreated
fn = File.Name
End If
End If
Next
Set Folder = Nothing
Else
'若文件夹路径不存在,给出错误提示并退出脚本运行
MsgBox "Folder " & LogPath & " not found!", vbExclamation
WScript.Quit
End If
'MsgBox fn '显示创建时间最新的文件名(不含路径),调试时可放开注释
'至此,得到文件名
我是从百度知道中的一个答案修改的,需要检索桌面上最新创建的.tif文件。现在已经检索出了最新tif的名字了。我想知道接下来加上什么语句能用quickmtf.exe这个程序打开这个检索出来的文件