I would like to generate a 2d barcode (PDF417 or QR codes) in an Excel cell using macros. Just wondering is there any free alternatives to paid libraries to do this?
I know certain tools can do the job but it is relatively expensive to us.
I would like to generate a 2d barcode (PDF417 or QR codes) in an Excel cell using macros. Just wondering is there any free alternatives to paid libraries to do this?
I know certain tools can do the job but it is relatively expensive to us.
I know this is quite an old and well-established post (though the very good existing answer has not been accepted yet), but I would like to share an alternative that I prepared for a similar post in StackOverflow in Portuguese using the free online API from QR Code Generator.
The code is the following:
It gets the job done by simply (re)creating an image from the URL built from the parameters in the cells. Naturally, the user must be connected to the Internet.
For example (the worksheet, with contents in Brazilian Portuguese, can be downloaded from 4Shared):
The VBA module barcode-vba-macro-only (mentioned by Sébastien Ferry in the comments) is a pure VBA 1D/2D code generator created by Jiri Gabriel under MIT License in 2013.
The code isn't completely simple to understand, but many comments have been translated from Czech to English in the version linked above.
To use it in a worksheet, just copy or import barcody.bas into your VBA in a module. In a worksheet, put in the function like this:
The usage is as follows:
CELL("SHEET)
andCELL("ADDRESS")
as they are since it's just giving reference to the worksheet and cell address you have the formulaI added wrapper functions to make it a pure VBA function call rather than using it as a formula in a worksheet:
With this wrapper, you can now simply call to render QRCode by calling this in VBA:
Just input the worksheet name, cell location, and the QR_value. The QR shape will get drawn at the location you specified.
You can play around with this section of the code to change the size of the QR