我是 VBS 的新手,我正在尝试创建一个对文件夹中的一些文件进行排序的脚本,如果满足条件,应该输出一个 MsgBox 以及打印文件。MsgBox 部分有效,但打印功能无效。感谢您的任何指导。
Option Explicit
Dim today_date, path
today_date = Date
path = "C:\Users\MyComputer\Desktop\FORMS"
Call GetRecentFile(path)
Function GetRecentFile(specify_path)
Dim fso, file, my_counter
my_counter = 0
Set fso = CreateObject("scripting.FileSystemObject")
For Each file In fso.GetFolder(specify_path).Files
If CDate(FormatDateTime(file.DateLAstModified, vbShortDate)) = Date Then
file.InvokeVerbEx ("Print")
my_counter = my_counter + 1
End If
Next
If my_counter = 1 Then
MsgBox "There is a new file in the folder: " & path, 0, "ATTENTION !"
ElseIf my_counter > 1 Then
MsgBox "There are " & my_counter & "file in the folder: " & path, 0, "ATTENTION !"
Else: MsgBox "There are no new files as of " & Now, 0, "NOTIFICATION"
End If
End Function