使用EXECL批量生成一维码
1、打开新建一个execl表格。
将所需要生成一位码的数据放置在第一列。

2、点击“ALT+F12”可以打开VBA程序编辑器。

3、点击插入,选择模块。就可以打开编辑界面了。
编辑界面一开始是空白的。


4、在空白的编辑界面输入下记代码:
Sub 批量生成条码()
Dim i%, str1$, str2$, str3$, d As Object
Set d = New DataObject
Application.ScreenUpdating = False
If Application.CountA(Range("A:A")) = 0 Then
MsgBox "A列单号为空,程序退出!"
Exit Sub
Else
i = Range("A65536").End(xlUp).Row
For j = 1 To i
If Cells(j, 1) <> "" Then
str1 = "<table><img src=""http://apps.99wed.com/360app/barcode/barcode.php?codebar=BCGcode128&text="
str2 = "&resolution=2&thickness=30"" > "
str3 = str3 & str1 & Cells(j, 1) & str2 & Chr(10)
End If
Next
d.SetText str3
d.PutInClipboard
Range("B1").Select
ActiveSheet.PasteSpecial Format:="Unicode 文本", Link:=False, DisplayAsIcon:=False
Columns(1).HorizontalAlignment = xlCenter
Columns(1).VerticalAlignment = xlCenter
Rows(1 & ":" & i).RowHeight = ActiveSheet.Pictures(1).Height
Columns(2).ColumnWidth = ActiveSheet.Pictures(1).Width / 6.13
End If
Application.ScreenUpdating = True
End Sub
Sub 批量删除条码()
Dim myshape As Shape
Application.ScreenUpdating = False
For Each myshape In ActiveSheet.Shapes
If myshape.Type = msoPicture Then
myshape.Delete
End If
Next
Application.ScreenUpdating = True
End Sub

5、然后点击工具,引用。将这4个内容打钩,便于程序进行引用,避免运行出错。

6、然后选择打开的execl,点击标题栏中的视图,选择最右侧的宏。
弹出的提示框有两个宏程序。
选择批量生成条码,点击运行。


7、运行后,可以看到所有的数据列都已经生成了条形码。

8、同样的操作,选择批量删除条码,可以批量删除刚才生成的一维码。
