前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >VB6 PDF批量打印,方便快速

VB6 PDF批量打印,方便快速

作者头像
一线编程
发布2019-07-22 11:37:40
2.1K0
发布2019-07-22 11:37:40
举报
文章被收录于专栏:办公魔盒办公魔盒



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

转载请注明出处!


本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-06-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 办公魔盒 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档