Sub
GenerateBarcodes()
Dim Barcode As Range
Dim Code As String
Dim i As Integer
' 假设条形码要保存在A列,从A2开始
Set Barcode = ThisWorkbook.Sheets(
"Sheet1"
).Range(
"A2"
)
' 假设条形码代码存储在B列,从B2开始
Set Barcode = ThisWorkbook.Sheets(
"Sheet1"
).Range(
"B2"
)
' 循环遍历所有条形码
Do Until Barcode.Value =
""
' 将条形码代码复制到剪贴板
Code = Barcode.Value
Application.CutCopyMode = False
Barcode.Copy
' 创建EAN-13条形码
With ActiveSheet.Pictures.Insert(
"https://barcode.io/barcode-generator-ean13.php?code="
& Code &
"&style=1&size=300&type=png"
)
' 将条形码保存在相应的单元格中
.Top = Barcode.
Offset
(0, 1).Top
.Left = Barcode.
Offset
(0, 1).Left
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.
Width
= Barcode.
Width
.ShapeRange.Height = Barcode.Height
End
With
' 下一个条形码
Set Barcode = Barcode.
Offset
(1, 0)
Loop
End
Sub