批量打印excel的一段代码,F8能打印出列表中所有excel文件,为何F5只能打印一张?
Private Sub Command3_Click()
Dim RetVal As Long
Dim ShExInfo As SHELLEXECUTEINFO
Dim I As Integer
Dim Mypathname As String
For I = 0 To List1.ListCount - 1
Mypathname = List1.List(I)
With ShExInfo
.cbSize = Len(ShExInfo)
.fMask = &H40
.hwnd = 0
.lpVerb = "print"
.lpFile = Mypathname
.lpParameters = ""
.lpDirectory = vbNullChar
.nShow = 0
End With
RetVal = ShellExecuteEx(ShExInfo)
If RetVal = 0 Then
Exit Sub
End If
Next
End Sub
Public Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type