|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test() '前期绑定
'VBE 工具栏-工具-引用 BarTender 10.1
'C:\Program Files (x86)\Seagull\BarTender Suite\BarTend.exe
Dim file_path As String
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Dim inti As Long, arr, i%, dic As Object
file_path = ThisWorkbook.Path & "\333.btw"
Set btApp = New BarTender.Application
btApp.Visible = True
Set btFormat = btApp.Formats.Open(file_path)
Set dic = CreateObject("scripting.dictionary")
With Sheet2
arr = .Range("A1:R" & .Range("G65536").End(xlUp).Row)
For i = 2 To UBound(arr)
If Not dic.exists(arr(i, 8)) Then
dic(arr(i, 8)) = ""
btFormat.SetNamedSubStringValue "VAR1", arr(i, 2)
btFormat.SetNamedSubStringValue "VAR2", arr(i, 17)
btFormat.SetNamedSubStringValue "VAR3", arr(i, 8)
btFormat.SetNamedSubStringValue "VAR4", arr(i, 5)
btFormat.SetNamedSubStringValue "VAR5", arr(i, 1)
btFormat.SetNamedSubStringValue "VAR6", arr(i, 7)
btFormat.SetNamedSubStringValue "VAR7", arr(i, 18)
btFormat.PrintSetup.IdenticalCopiesOfLabel = arr(i, 18)
btFormat.PrintOut
End If
Next
End With
btFormat.Close btDoNotSaveChanges
btApp.Quit
Set btFormat = Nothing
Set btApp = Nothing
End Sub
比如说这段代码可以打印出标签来,循环一次打印一个,打印机就会走一行,如果我有100个标签每个打印一张,但是标签是双排的纸正常打印完只要50行就行了,但是实际运行时就会每一行只会打印一列有一列会空着要打100行很浪费纸,这情况怎么解决。有没办法实现类似于先写入缓存后一次性输出打印的方法。 |
|