Chapter 6. Adding QR Codes in Microsoft Office

To insert a QR Code symbol into Office document, you can create the barcode in QRCode Encoder GUI and transfer it through clipboard. In Word, you can also use the Word AddIn included in the software. Either way, you can't change the barcode because the barcode image does not have the information of the data encoded. If you need to create QR code images on the fly in a Microsoft Office program, you can select either ActiveX control or font-based. It depends on the exact situation - in some cases ActiveX control based is better and may be the only solution supported; and in other cases font-based solution is better. In this chapter we'll overview several typical scenarios.

6.1. VBA Module

Microsoft Office programs, including Word, Excel and Access, can not call DLL functions directly. Instead, you need to import the VBA module included into your document first. This module adds function to create barcode string of a QR code.

Table 6.1. List of VBA Functions (Morovia.QRCodeFontDLL5.bas)

Function PrototypeFont to UseComment
QRCodeEncode(DataToEncode As String, _
      Optional versionID As Long=0, _
      Optional ecLevel As Long=0) As String
MRV QRCodeReturns the barcode string that with DataToEncode encoded.

Note that the version and error correction level parameters are optional. So you can call the function as below:

barcodestr = QRCodeEncode("this is data")

6.1.1. To Import VBA Module

To import the QR code VBA module, perform the following steps:

  1. In Office 2003, Select ToolsMacroVisual Basic Editor to launch Visual Basic Editor. In Office 2007 and above, first enable developer tab if you can't see it. Then click on Developer tab followed by Visual Basic.

  2. Choose FileImport File. Navigate to QRCode Fonts & Encoder installation folder, by default c:\program files (x86)\Morovia QRCode Fonts & Encoder 5 [3], and select Morovia.QRCodeFontDLL5.bas.

  3. Close Visual Basic Editor and save the file.

  4. After the VBA is imported successfully, formula QRCodeEncode is available to use.



[3] On 32-bit Windows the directory is c:\program files\Morovia QRCode Fonts & Encoder 5