|
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Const SW_HIDE As Long = 0
Sub test()
Dim filename(), n, pth, mark, fso
Dim str1199 As String
Set fso = CreateObject("scripting.filesystemobject")
str1199 = InputBox("输入一个文件夹: ", "文件位置")
pth = str1199 & "\"
mark = ".pdf" '文件类型
Call getfilename(fso, filename, n, pth, mark)
If n = 0 Then Exit Sub
For Each f In filename
ShellExecute Application.hwnd, "print", f, "", "", SW_HIDE
Next f
End Sub
Sub getfilename(fso, filename, n, pth, mark)
Dim spth, t
If Right(pth, 1) <> "\" Then pth = pth & "\"
Set spth = fso.getfolder(pth)
For Each t In spth.Files
If LCase(Right(t, Len(mark))) = LCase(mark) Then
n = n + 1: ReDim Preserve filename(1 To n)
filename(n) = spth & "\" & t.Name
End If
Next
For Each t In spth.subfolders
getfilename fso, filename, n, t, mark
Next
End Sub
ShellExecute Application.hwnd, "print", f, "", "", SW_HIDE 代码超过30份后,电脑自动死机,怎么改 让超过10000份打印不死机? |
|
|