How to embed a QR code in an Excel package

Posted on 2/18/2022

QRCodes, and especially since the COVID Outbreak, are now part of everyday's life. Created in 1994 by Denso-Wave, they have been released to the public in 1999 so that everyone can use them. There is a lot of ways to generate them, some cheaper than others, but I will teach you a method to create them in your Excel packages for free.

Use cases

You can use the library to generate QRCode, but EAN-13 and other codbars if you wish. This might require to download a font included in the package, but will not be covered here. You can embed a url in the data of the QRCode, and use it as a way to authenticate the data contained in your excel package, by providing a link to your ERP dashboard giving you an aggregated view of what is more detailed in your excel file, or you can use it to mass generate QRCode , the choice is yours.

How to insert a QR code in excel

  1. First of all, you will need to visit this link:
  2. As I suspect you, my dear reader, are not a seasoned developer knowing the intricacies of Github, let's just download the zip file
  3. In the zipfile, you will find the file barcody.bas. This is a visual basic file that you can import in the macro editor.
  4. Importvba
  5. Now in your Excel file you can use a formula like
  1. The first argument in the function is the worksheet number
  2. The second is a reference for the cell address
  3. The third is the cell containing the data you want to be encoded, in our case the address to be used in our ERP system
  4. the fourth 51 is the option for QR Code. Other options are 1=EAN8/13/UPCA/UPCE, 2=two of five interleaved, 3=Code39, 50=Data Matrix, 51=QRCode
  5. The fifth 1 is for graphical mode. The barcode is drawn on a Shape object.
  6. the sixth 0 is the parameter for the particular barcode type. For QR_Code, 0=Low Error Correction, 1=Medium Error Correction, 2=Quartile error correction, 3=high error correction.
  7. 2 only applies to 1D codes.
  8. A shape object will be generated containing the QR code.

Et voilà ! You can now have a direct and independant way to embed QRCodes in your Excel packages.

Last remarks

As mentioned earlier, this might not be the most performant method to have QRCode in your excel package, but it is a full vba macro and does not require any link to any external library. If you wanted to have a more robust method to mass generate QR codes, I would use a pyhton script using the QRCode library. If you want me to explain this method, please leave a request in the comments.