1

I'm trying to crate and display a whole series of QR codes (200+) in an excel sheet running on Mac. The first solution given by Patratacus found on Generating 2D (PDF417 or QR) barcodes using Excel VBA takes a long time to run so many codes and because the QR Codes are made up of multiple shapes the screen refresh becomes really slow with 200+ QR codes on one sheet.

So, I have got the code working on PC using @Luiz solution found at Generating 2D (PDF417 or QR) barcodes using Excel VBA but unfortunately it doesn't seem to work on Mac.

With the code:

sURL = "https://api.qrserver.com/v1/create-qr-code/?" + "size=" + Trim(Str(size)) + "x" + Trim(Str(size)) + "&color=" + color + "&bgcolor=" + bgcolor + "&data=" + data
Debug.Print sURL

Set pic = ActiveSheet.Pictures.Insert(sURL + sParameters)

SURL + sParameters - seems to return the raw data of the image from the API https://api.qrserver.com/v1/create-qr-code/?. So I have been able to get a Mac shell script to return the same raw data I think using:

sResult = execShell(= "curl --get -d """ & "size=" + Trim(Str(size)) + "x" + Trim(Str(size)) + "&color=" + color + "&bgcolor=" + bgcolor + "&data=" + data & """" & " " & "https://api.qrserver.com/v1/create-qr-code/?")

However, if you insert the returned string into:

ActiveSheet.Pictures.Insert()

On mac it doesn't seem to work either. So my guess is that on Mac ActiveSheet.Pictures.Insert() is not able to read raw image data and only a path and file name to a picture file.

So I think our options are:

  1. Find a why to display a picture on an excel sheet using the raw data returned by the API or

  2. Find a way to save the raw data returned by the API as a picture file on Macs file system and then open that file using excels ActiveSheet.Pictures.Insert() code.

Here is a link to the API documentation page: http://goqr.me/api/doc/create-qr-code/

I hope what I wrote above make some sense as I probably don't have all the terminology correct. I'm quite new to working with APIs etc.

Community
  • 1
  • 1
Tristan
  • 163
  • 2
  • 10

0 Answers0