RubyPDF Blog software Pure VBA Macro to Generate Barcode for LibreOffice and MS Office

Pure VBA Macro to Generate Barcode for LibreOffice and MS Office

barcode-vba-macro-only is a barcode generator with the following features,

  • Pure vba macro
  • Support EAN8, EAN13, UPCA, UPCE, Code39, DataMatrix, QRCode, Code128
  • Support LibreOffice(OpenOffice) and MS Office
  • Totally Free and Open source

To use it in a worksheet, just copy or import barcody.bas into your VBA in a module. In a worksheet, just put in the function like this:


The usage is as followed:

  • Leave the CELL(“SHEET) and CELL(“ADDRESS”) as they are since it’s just giving reference to the worksheet and cell address you have the formula
  • A2 is the cell that you have your string to be encoded. In my case it’s cell A2 You can pass “Text” with quotes to do the same. Having the cell makes it more dynamic
  • 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
  • 1 is for graphical mode. The barcode is drawn on a Shape object. 0 for font mode. I assume you need to have the font type installed. Not as useful.
  • 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.
  • 2 only applies to 1D codes. It’s the buffer zones. I’m not certain what it does exactly but probably something to do with the 1D bar spaces?


Generating 2D (PDF417 or QR) barcodes using Excel VBA

1 thought on “Pure VBA Macro to Generate Barcode for LibreOffice and MS Office”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.