vb导入数据到EXCEL 条形码如何导入

nicholasvb 2011-05-26 08:40:26
vb做的出货单 打印的的时候 首先把数据导入到excel中 客户要求要含有他们制定的条形码 这个语句怎么写 ??
在EXCEL 利用宏生成条形码是这样的 :
''----- 第五行,条码行 --
.Range(AmountCell(StartCol) & CStr(StartRow + 4) & ":" & AmountCell(EndCol) & CStr(StartRow + 4)).Select
Selection.Merge

ActiveCell.FormulaR1C1 = "*" & barpo & barboxqty & pack & Chr(47) & packnum & "*"

With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Name = BARCODE_FONT_NAME
.Font.Size = BARCODE_FONT_SIZE
.Font.Bold = False
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = True
.ReadingOrder = xlContext
.MergeCells = True
End With
这是在excel 的vba中生成的条形码

那如何在vb中 例如导出数据时让 range("A5:D5") = 条形码呢??
...全文
282 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
luckyroot 2011-07-20
  • 打赏
  • 举报
回复
我用VB导出数据到EXCEL中,并添加BARCODE控件到EXCEL中,为什么把EXCEL中的BARCODE赋值了,要预览EXCEL才能显示出条形码。。没有预览的话是空白。为什么。
booksoon 2011-05-26
  • 打赏
  • 举报
回复
那你添加条码字体了吗?
nicholasvb 2011-05-26
  • 打赏
  • 举报
回复
barpo & barboxqty & pack & Chr(47) & packnum & "*" 这些变量好像是前面的代码中的




'' 生成具体表
''--------------------------------
Sub InitTableStyle(PONo As String, rowno As Integer, Index As Integer, LabelCount As Integer, StartRow As Integer, EndRow As Integer, StartCol As Integer, EndCol As Integer)

Dim barboxqty As String 'Barcode的Boxqty
Dim barcode As String, barpo As String

Dim pack As String 'Barcode号
Dim packnum As String 'Barcode的捆包个数
Dim i As Integer, j As Integer
Dim strpo As String, strcostomno As String, strcostomname As String, strboxqty As Integer, strqty As Integer, strpacknum As String

Dim strpartno As String, strorg As String, datefob As String, dateissue As String

Dim iQty As Integer, iBoxQty As Integer, iModQty As Integer
iQty = CInt(Worksheets("Input").Cells(rowno, 2))
iBoxQty = CInt(Worksheets("Input").Cells(rowno, 3))
If iQty Mod iBoxQty > 0 Then
iModQty = iQty Mod iBoxQty
Else
iModQty = 0
End If


strpo = Worksheets("Input").Cells(rowno, 1)
strcostomno = Worksheets("Input").Cells(1, 2)
strcostomname = Worksheets("Input").Cells(1, 4)
If iModQty = 0 Or Index < LabelCount Then
strboxqty = Worksheets("Input").Cells(rowno, 3)
Else
strboxqty = iModQty
End If

strqty = Worksheets("Input").Cells(rowno, 2)
strpacknum = CStr(Index) & CStr(Chr(47)) & CStr(LabelCount)
strpartno = Worksheets("Input").Cells(rowno, 4)
strorg = Worksheets("Input").Cells(rowno, 5)
datefob = Worksheets("Input").Cells(rowno, 6)
dateissue = Worksheets("Input").Cells(rowno, 7)

barpo = CStr(strpo)

If Len(Trim(barpo)) < 12 Then

j = 12 - Len(Trim(barpo))

For i = 1 To j

barpo = barpo & " "

Next

End If


barboxqty = CStr(strboxqty)

If Len(Trim(strboxqty)) < 5 Then

j = 5 - Len(Trim(strboxqty))


For i = 1 To j

barboxqty = "0" & barboxqty

Next

End If

pack = CStr(Index)

If Len(Trim(Index)) < 2 Then

pack = "0" & CStr(Index)

End If

packnum = CStr(LabelCount)

If Len(Trim(LabelCount)) < 2 Then

packnum = "0" & LabelCount

End If
booksoon 2011-05-26
  • 打赏
  • 举报
回复
这一句不知啥意思啊ActiveCell.FormulaR1C1 = "*" & barpo & barboxqty & pack & Chr(47) & packnum & "*"
nicholasvb 2011-05-26
  • 打赏
  • 举报
回复
谢谢 你 如何调啊 我这样怎么不显示啊
.Range( "A5:D5" ).Select
Selection.Merge

ActiveCell.FormulaR1C1 = "*" & barpo & barboxqty & pack & Chr(47) & packnum & "*"

With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Name = BARCODE_FONT_NAME
.Font.Size = BARCODE_FONT_SIZE
.Font.Bold = False
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = True
.ReadingOrder = xlContext
.MergeCells = True
End With
打印出来 A5:D5是空的啊
booksoon 2011-05-26
  • 打赏
  • 举报
回复
调整好BARCODE的left,top,height,width属性让它对齐a5:d5

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧