CryptoSys Home > diQRcode > Using diQRcode in Excel

Using diQRcode in Excel


Example spreadsheet

The Excel spreadsheet diQRcode.xls (zipped, 27 kB) shows how to create QR code GIF files from Excel.

XLS

This is an adaptation of the Excel spreadsheet in How to convert VBA/VB6 Unicode strings to UTF-8.

Add a new button: View > Toolbars > Forms, click on the "Button" option and use the cursor to add it to your page**, then assign a macro to it and click "New". In this example we add the macro btnHebrew_Click

Assign Macro

** Procedure to add a button may vary depending on your version of Excel. We're using our old trusty Excel 2003 here (we hate that ribbon in newer versions).

VBA code

Sub btnHebrew_Click()
    Dim strFile As String
    Dim strData As String
    strData = Worksheets("Sheet1").Cells(9, 1)
    strFile = ActiveWorkbook.Path & "\" & Worksheets("Sheet1").Cells(9, 5)
    Call CreateGifFromCells(strFile, strData)
End Sub

Public Function CreateGifFromCells(strOutputFile As String, strInput As String) As Long
    CreateGifFromCells = qrcodeCreateGifInUtf8(strOutputFile, strInput)
    If CreateGifFromCells = 0 Then
        MsgBox "Created file " & strOutputFile
    Else
        MsgBox "Error " & CreateGifFromCells & ": " & qrcodeErrorLookup(CreateGifFromCells)
    End If
End Function

When you click on the "CreateGif" button, it gets the Unicode text from the cell on the left and the name of the output file to create from the cell on the right, and passes these to the common CreateGifFromCells function, which calls the qrcodeCreateGifInUtf8 function in basQRcode.bas.

Note how the code uses the qrcodeCreateGifInUtf8 function, not the basic qrcodeCreateGif, in order to pass the complete Unicode characters (if you just used qrcodeCreateGif, most examples above would give you error code -11 OUT_OF_RANGE_ERROR.)

Results

ascii.gif
ascii.gif
spa.gif
spa.gif
jap.gif
jap.gif
chi.gif
chi.gif
heb.gif
heb.gif

Contact us

To contact us or comment on this page, please send us a message.

This page last updated 6 April 2021

[Go to top]