|
Sub AddBarcode()
Dim iCount&, i
Call del '删除已有的条形码
iCount = Sheet1.[a65536].End(xlUp).Row
Sheet1.Range("b:b").ColumnWidth = 25
Sheet1.Rows.RowHeight = 50
For i = 1 To iCount
With Sheet1.OLEObjects.Add(ClassType:="BARCODE.BarCodeCtrl.1")
.Object.Style = 7
.Object.Value = Format(Sheet1.Cells(i, 1).Value, "000000000000") '12位及以上
.Height = Sheet1.Cells(i, 2).Height
.Width = Sheet1.Cells(i, 2).Width
.Left = Sheet1.Cells(i, 2).Left
.Top = Sheet1.Cells(i, 2).Top
End With
Next
End Sub
Sub del()
Dim txm As Shape
For Each txm In Sheet1.Shapes
If txm.Type <> 8 Then txm.Delete
Next
End Sub |
|