|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
"简单点,网络版代码
- Sub 生成二维码()
- Dim r, arr, i, c, j, k, s As String, rr, b As Boolean, n, ewm
- Dim Ran As Range
- On Error Resume Next
- Call 清空内容及二维码
- With Sheets("二维码内容")
- r = .[A65536].End(xlUp).Row
- arr = .Range("A1:M" & r).Value
- End With
- b = True
- For i = 2 To UBound(arr)
- s = "": n = 2 + (Int(i / 2) - 1) * 13
- For c = 2 To UBound(arr, 2)
- If s = "" Then s = arr(i, c) Else s = s & "|" & arr(i, c)
- Next
- With Sheets("标签")
- If b = True Then
- For c = 2 To UBound(arr, 2) - 1
- .Range("B" & n + c - 2) = arr(i, c)
- Next
- .Range("D" & n + 3) = arr(i, UBound(arr, 2))
- Set Ran = .Range("C" & n).MergeArea
- b = False
- Else
- For c = 2 To UBound(arr, 2) - 1
- .Range("G" & n + c - 2) = arr(i, c)
- Next
- .Range("I" & n + 3) = arr(i, UBound(arr, 2))
- Set Ran = .Range("H" & n).MergeArea
- b = True
- End If
- ewm = 生成二维码Fun(s, Ran)
- Application.Wait Now + TimeValue("00:00:02")
- End With
- Next
- MsgBox "ok!"
- End Sub
- Sub 清空内容及二维码()
- Dim myshape As Shape
- On Error Resume Next
- Application.ScreenUpdating = False
- For Each myshape In ActiveSheet.Shapes
- 'If myshape.Type = msoPicture Then
- If myshape.Left < Range("K1").Left Then
- myshape.Delete
- End If
- Next
- Dim r, arr, i, c, j, k, s As String, rr, b As Boolean, n, ewm
- On Error Resume Next
- r = Sheets("二维码内容").[A65536].End(xlUp).Row
- b = True
- For i = 2 To r
- n = 2 + (Int(i / 2) - 1) * 13
- With Sheets("标签")
- If b = True Then
- For c = 2 To 12
- .Range("B" & n + c - 2) = ""
- Next
- .Range("D" & n + 3) = ""
- b = False
- Else
- For c = 2 To 12
- .Range("G" & n + c - 2) = ""
- Next
- .Range("I" & n + 3) = ""
- b = True
- End If
- End With
- Next
- Application.ScreenUpdating = True
- End Sub
- Function 生成二维码Fun(ByVal Str As String, ByVal Rng As Range)
- Dim CelH, CelW, PicH, PicW, Picbili
- On Error Resume Next
- Rng.Select
- 'URL = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & Str
- URL = "http://e.anyoupin.cn/pdo/eh/a10/create_qr.php?value=" & Str
- ActiveSheet.Pictures.Insert(URL).Select
- With Selection
- CelH = Rng.Height
- CelW = Rng.Width
- PicH = .Height
- PicW = .Width
- Picbili = Application.WorksheetFunction.Min(CelH / PicH, CelW / PicW) * 0.98
- .Height = PicH * Picbili
- .Width = PicW * Picbili
- .Top = Rng.Top + (Rng.Height - .Height) / 2 '垂直居中:
- .Left = Rng.Left + (Rng.Width - .Width) / 2 '水平居中:
- End With
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|