Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 14111|回复: 6

[分享] vba 調用Bartender 打印 條碼

[复制链接]
发表于 2013-4-22 19:00 | 显示全部楼层 |阅读模式
現在熱門的條碼打印軟件一個是Bartender,一個是codesoft , 用vba怎麼樣實現調用Bartender軟件打印你要的條碼呢?
下面的代碼幫你解決問題。
請你在模板上將變量改為共享變量。

Sub Print_carton()
Dim file_path As String
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
file_path = "C:\Lab\aa.btw"

'----------------------------------------------------------------------
'Order bartender print lab as  templet
'----------------------------------------------------------------------
Set btApp = CreateObject("bartender.application")
btApp.Visible = False
Set btFormat = btApp.Formats.Open(file_path)
'---------------------------------------------------------------------
' Assignment a value to variable.
'---------------------------------------------------------------------
     btFormat.SetNamedSubStringValue "Var1", Cells(2, 1)
    btFormat.SetNamedSubStringValue "Var2", Cells(3, 1)
' Implement print
btFormat.PrintOut
btFormat.Close btDoNotSaveChanges
btApp.Quit
End Sub

希望對你有幫助!
发表于 2013-5-17 09:52 | 显示全部楼层
请问高手,我想打印一个文件
file_path = "C:\Users\Erick\Desktop\1\MODULE.btw" 但是报错

代码是这个

Sub Print_carton()
Dim file_path As String
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
file_path = "C:\Users\Erick\Desktop\1\MODULE.btw"

'----------------------------------------------------------------------
'Order bartender print lab as  templet
'----------------------------------------------------------------------
Set btApp = CreateObject("bartender.application")
btApp.Visible = False
Set btFormat = btApp.Formats.Open(file_path)
'---------------------------------------------------------------------
' Assignment a value to variable.
'---------------------------------------------------------------------
      btFormat.SetNamedSubStringValue "Var1", Cells(2, 1)
     btFormat.SetNamedSubStringValue "Var2", Cells(3, 1)
' Implement print
btFormat.PrintOut
btFormat.Close btDoNotSaveChanges
btApp.Quit
End Sub
回复

使用道具 举报

 楼主| 发表于 2013-5-17 13:42 | 显示全部楼层
liuboru 发表于 2013-5-17 09:52
请问高手,我想打印一个文件
file_path = "C:\Users\Erick\Desktop\1\MODULE.btw" 但是报错

你需要在模板中設置參數的值,在代碼中你需要修改Var1和Var2 的值,
報什麽樣的錯?截圖看一下。
回复

使用道具 举报

发表于 2013-8-9 17:11 | 显示全部楼层
怎么Dim btApp As BarTender.Application 就报错,用户 定义 类型未定义
回复

使用道具 举报

发表于 2013-9-7 07:59 | 显示全部楼层
这些天一直想用这种方式打印barcode,终于搞定了,以上说法基本正确,就是需要bartender的版本和加载资源上注意下!
回复

使用道具 举报

发表于 2015-2-7 06:34 | 显示全部楼层
请问高手:btFormat.SetNamedSubStringValue语句是什么含义?var1\var2值修改的依据是什么?谢谢!
回复

使用道具 举报

发表于 2022-6-25 08:27 | 显示全部楼层
如何修改圖片,由外部圖片更新
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-17 03:42 , Processed in 0.272046 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表