VB6代码 PDF批量打印,方便快速!!
Option Explicit
Private Declare Function ShellExecuteEx Lib "shell32.dll" Alias "ShellExecuteExA" (lpExecInfo As SHELLEXECUTEINFO) As Long
Private 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
Dim OldW As Single
Dim OldH As Single
'***************************************************************************
Private Sub Combo1_Change()
'If i.DeviceName = Combo1.Text Then Set Printer = i: Exit For
'Printer = Combo1.Text
End Sub
Private Sub Command2_Click()
Text3.Text = ""
CommonDialog1.Flags = cdlPDAllPages Or cdlPDPageNums Or cdlPDSelection Or cdlPDCollate Or cdlPDPrintSetup
CommonDialog1.ShowPrinter
Text3.Text = Printer.DeviceName
End Sub
Private Sub Command3_Click()
Text1 = ""
End Sub
'******************************************************************************
'窗口大小发生改变时
Private Sub Form_Resize()
On Error Resume Next
'最小大小,防止比例失调
If Me.Width < 4800 Then Me.Width = 4800
If Me.Height < 3600 Then
Me.Height = 3600
Exit Sub
End If
Dim cu As Control
For Each cu In Me.Controls
'调整大小
cu.Move cu.Left * Me.Width / OldW, cu.Top * Me.Height / OldH, cu.Width * Me.Width / OldW, cu.Height * Me.Height / OldH
Next
'赋值
OldW = Me.Width
OldH = Me.Height
End Sub
Private Sub Command1_Click()
'On Error Resume Next
If IPValid("127.0.0.1") Then
Dim G
If Text1 = "" Then
MsgBox "请输入产品编码后继续操作"
End If
If IPValid("127.0.0.1") Then
For G = 0 To List1.ListCount - 1
If Dir("\\127.0.0.1\pdf\" & List1.List(G) & ".pdf ") <> "" Then
Else
MsgBox "PDF主机上没有 [" & List1.List(G) & "] 请下载后继续操作"
Exit Sub
End If
Next
Else
MsgBox "请检查PDF文件主机是否已启动"
End If
' If Text1 = "" Then
' MsgBox "请输入产品编码后继续操作"
' End If
Else
MsgBox "请检查PDF文件主机是否已启动"
End If
Dim RetVal As Long
Dim ShExInfo As SHELLEXECUTEINFO
Dim a, b, pdf
If IPValid("127.0.0.1") Then
For pdf = 0 To List1.ListCount - 1
ShExInfo.cbSize = Len(ShExInfo)
ShExInfo.fMask = &H40
ShExInfo.hwnd = 0
ShExInfo.lpVerb = "print"
ShExInfo.lpFile = "\\10.28.14.36\pdf\" & List1.List(pdf) & ".pdf"
ShExInfo.lpParameters = ""
ShExInfo.lpDirectory = vbNullChar
ShExInfo.nShow = 0
RetVal = ShellExecuteEx(ShExInfo)
If RetVal = 0 Then
Exit Sub
End If
Next pdf
Else
MsgBox "请检查PDF文件主机是否已启动"
End If
End Sub
Private Sub Form_Load()
' Combo1.Clear
'Dim i As Printer
'For Each i In Printers
'Text2.Text = Text2.Text & i.DeviceName & vbCrLf
''Next
'
' Dim a, b
' a = Split(Text2.Text, vbCrLf)
' For b = LBound(a) To UBound(a)
' Combo1.AddItem a(b)
' Next
End Sub
Private Sub List1_dblClick()
On Error Resume Next
If IPValid("127.0.0.1") Then
FoxitCtl1.OpenFile ("\\127.0.0.1\pdf\" & List1.Text & ".pdf")
Else
MsgBox "请检查PDF文件主机是否已启动"
End If
End Sub
Private Sub Text1_Change()
On Error Resume Next
List1.Clear
Dim a, b
a = Split(Text1.Text, vbCrLf)
For b = LBound(a) To UBound(a)
List1.AddItem a(b)
Next
End Sub
具体代码及插件自行下载体验!
链接:https://pan.baidu.com/s/135UYwqovmE6nGRv-NERisA 密码:mznx
转载请注明出处!