|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 VBA万岁 于 2015-8-26 16:06 编辑
以下第2段代码是用Excel矩形加载网页条码图片的,不知条码枪能否识别?
- <P>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("A1048576").End(xlUp).Row
- For j = 1 To i
- If Cells(j, 1) <> "" Then
- str1 = "<table><img src=""<A href="http://barcode.cnaidc.com/html/cnaidc.php?filetype=PNG&dpi=72&scale=1&rotation=0&font_family=Arial.ttf&font_size=14&text">http://barcode.cnaidc.com/html/cnaidc.php?filetype=PNG&dpi=72&scale=1&rotation=0&font_family=Arial.ttf&font_size=14&text</A>="
- str2 = "&thickness=30&checksum=&code=BCGcode39"" ></table> "
- str3 = str3 & str1 & Cells(j, 1) & str2 & Chr(10)
- End If
- Next
- d.SetText str3
- d.PutInClipboard
- Range("B" & Range("A1").End(xlDown).Row).Select
- ActiveSheet.Paste
- Rows(1 & ":" & i).RowHeight = ActiveSheet.Pictures(1).Height
- Columns(2).ColumnWidth = ActiveSheet.Pictures(1).Width / 5.13
- End If
- Application.ScreenUpdating = True
- End Sub</P>
- <P>Sub 生成条码2()
- Dim Shp
- For Each Shp In ActiveSheet.Shapes
- If Left(Shp.Name, 6) <> "Button" Then Shp.Delete
- Next
- Rows(Range("A1").End(xlDown).Row & ":" & Cells(Rows.Count, 1).End(xlUp).Row).RowHeight = 51.25
- For Each cel In Range("a" & Range("A1").End(xlDown).Row & ":a" & Cells(Rows.Count, 1).End(xlUp).Row)
- str1 = "<A href="http://barcode.cnaidc.com/html/cnaidc.php?filetype=PNG&dpi=72&scale=1&rotation=0&font_family=Arial.ttf&font_size=14&text">http://barcode.cnaidc.com/html/cnaidc.php?filetype=PNG&dpi=72&scale=1&rotation=0&font_family=Arial.ttf&font_size=14&text</A>="
- str2 = "&thickness=30&checksum=&code=BCGcode39"
- cel.Offset(, 2).Select
- ActiveSheet.Shapes.AddShape(msoShapeRectangle, cel.Offset(, 2).Left, cel.Offset(, 2).Top, cel.Offset(, 2).Width, cel.Offset(, 2).Height).Select
- Selection.ShapeRange.Fill.UserPicture str1 & cel.Value & str2
- Next
- End Sub
- </P>
复制代码 |
|