Is there a way to call a macro in Excel that converts specified cells values to separate QR-codes and places them on specific locations?
Following code has worked until today. I guess the api.qrserver.com doesn't allow several calls as an anti-spam filter, or it's just trouble for today. One single call by the URL works fine.
I would like a local solution if possible that doesn't rely on up/downtime for api.qrserver.com.
Sub addQR()
For Each pic In ActiveSheet.Pictures
pic.Delete
Next pic
filepath = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & Cells(3, 18).Value
With ActiveSheet.Pictures.Insert(filepath)
.ShapeRange.ScaleWidth 0.8, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight 0.8, msoFalse, msoScaleFromTopLeft
.Left = ActiveSheet.Range("I1").Left
.Top = ActiveSheet.Range("C4").Top
.Width = ActiveSheet.Range("A1:B1").Width
.Height = ActiveSheet.Range("A1:A5").Height
.Placement = 1
End With
filepath2 = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & Cells(5, 18).Value
With ActiveSheet.Pictures.Insert(filepath2)
.ShapeRange.ScaleWidth 0.8, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight 0.8, msoFalse, msoScaleFromTopLeft
.Left = ActiveSheet.Range("G11").Left
.Top = ActiveSheet.Range("G11").Top
.Width = ActiveSheet.Range("A1:B1").Width
.Height = ActiveSheet.Range("A1:A5").Height
.Placement = 1
End With
filepath3 = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & Cells(7, 18).Value
With ActiveSheet.Pictures.Insert(filepath3)
.ShapeRange.ScaleWidth 0.8, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight 0.8, msoFalse, msoScaleFromTopLeft
.Left = ActiveSheet.Range("E21").Left
.Top = ActiveSheet.Range("E21").Top
.Width = ActiveSheet.Range("A1:B1").Width
.Height = ActiveSheet.Range("A1:A5").Height
.Placement = 1
End With
filepath4 = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & Cells(9, 18).Value
With ActiveSheet.Pictures.Insert(filepath4)
.ShapeRange.ScaleWidth 0.8, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight 0.8, msoFalse, msoScaleFromTopLeft
.Left = ActiveSheet.Range("L21").Left
.Top = ActiveSheet.Range("L21").Top
.Width = ActiveSheet.Range("A1:B1").Width
.Height = ActiveSheet.Range("A1:A5").Height
.Placement = 1
End With
picPath = "O:\Robin\Dokument\logga.jpg"
With ActiveSheet.Pictures.Insert(picPath)
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.ScaleWidth 1.78, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight 1.24, msoFalse, msoScaleFromTopLeft
.Left = ActiveSheet.Range("B3").Left
.Top = ActiveSheet.Range("B3").Top
.Placement = 1
End With
End Sub