=IMAGE('https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='&A2)
本例中,它的第1參數(shù)是qrserver.com的QR CODE API接口,可以公開(kāi)、免費(fèi)、穩(wěn)定的生成二維碼。
換句話說(shuō),我們把qrserver.com生成二維碼的網(wǎng)址給它,剩下的事就讓它去操心,咱們躺收其成就行了。
Sub GetQRCode()
Range('b1').Select
ActiveSheet.Pictures.Insert ('https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=' & Range('a1').Value)
End Sub
Sub GenerateQRCode()
Dim rng As Range, cell As Range
Dim shp As Shape, img As Picture, url As String
Application.ScreenUpdating = False
For Each shp In ActiveSheet.Shapes
If shp.Type = 11 Then shp.Delete
Next
Set rng = Range('A2:A' & Cells(Rows.Count, 'A').End(xlUp).Row)
rng.RowHeight = 60 '調(diào)整行高
rng.Offset(0, 1).ColumnWidth = 15 '調(diào)整隔壁列列寬
For Each cell In rng
If Len(cell.Value) Then
url = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=' & cell.Value
Set img = ActiveSheet.Pictures.Insert(url, False)
With cell.Offset(0, 1)
img.Top = .Top + 3
img.Left = .Left + 3
img.Width = .Width
img.Height = .Height - 6
End With
End If
Next
Application.ScreenUpdating = True
MsgBox '處理完成。', , '公眾號(hào)Excel星球'
End Sub
ActiveSheet.Pictures.Insert('https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=' & Range('a1').Value)
聯(lián)系客服