使用EXECL批量生成一维码
的有关信息介绍如下:

在工作过程中,有时候需要生成大量的一维码,在没有专业的软件的时候,自己很难做到。网上有很多APP要自己一个个去输入生成,浪费时间精力。
我这里通过编辑VBA程序,可以实现批量生成一维码。
打开新建一个execl表格。
将所需要生成一位码的数据放置在第一列。
点击“ALT+F12”可以打开VBA程序编辑器。
点击插入,选择模块。就可以打开编辑界面了。
编辑界面一开始是空白的。
在空白的编辑界面输入下记代码:
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 = "
![]()
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
然后点击工具,引用。将这4个内容打钩,便于程序进行引用,避免运行出错。
然后选择打开的execl,点击标题栏中的视图,选择最右侧的宏。
弹出的提示框有两个宏程序。
选择批量生成条码,点击运行。
运行后,可以看到所有的数据列都已经生成了条形码。
同样的操作,选择批量删除条码,可以批量删除刚才生成的一维码。
相关文章
-
2026-05-25 12:14
阅读(1004)
-
2026-05-25 12:21
阅读(1004)
-
2026-05-25 13:49
阅读(1004)