QR Code generator, text from multiple cells

ph1l

New Member
Joined
Dec 7, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I saw some great threads here, but none with answers to my questions.

I have one sheet, where I print labels, based on text from !$B$10:$B$16
I want to insert a QR code into $C$10, based on data / text from !$B$10:$B$16
It would be awesome, if the QR code gets updated, when new data / text has been inserted to any cell, at !$B$10:$B$16
The QR code could be generated from the Google API, or whatever you can recommend.

Can anyone crack this hard nut? ;)
 
H! :)

Interesting problem. Not sure which barcode generator you need to use or prefer to use, but I've found one called zint that I like. It's free, open source, doesn't require an online connection, includes both a decent GUI and command line solutions, and has pretty good documentation. I had never tried it from the command line before (which we need to do if running it from a VBA script), but I was able to piece things together nicely from its documentation.

I played around a little with it myself and ended up with the following, called from the Worksheet_Change event:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$10" Then
        'Delete existing QR code in worksheet
        Dim pic As Shape
        For Each pic In Sheet3.Shapes
            If pic.Name = "QR Code" Then pic.Delete
        Next pic
       
        'Create new QR code
        Dim data As String
        Dim qr As Picture
        Dim qrImagePath As String
        data = Sheet3.Range("B10").value
        qrImagePath = "C:\Users\%username%\Downloads\zint_win32_snapshot_2021-07-02\2021-07-02\qr.png"
   
        Shell "C:\Users\%username%\Downloads\zint_win32_snapshot_2021-07-02\2021-07-02\zint.exe zint -b 104 -d """"" & data & """"" -o " & qrImagePath & " --scale 5"
        Set qr = Sheet3.Pictures.Insert("C:\Users\%username%\Downloads\zint_win32_snapshot_2021-07-02\2021-07-02\qr.png")
        qr.Left = Sheet3.Range("C10").Left
        qr.Top = Sheet3.Range("C10").Top
        qr.PrintObject = True
        qr.Name = "QR Code"
    End If
End Sub

You'll need to change: the worksheet you want to use, the path pointing to zint.exe, the location where you want to save the QR image, and the location in the worksheet you want the image to be. You also might want to play around with the cmd line a little to customize the output exactly how you want it. -b 104 is telling it to export as HIBC QR Code type, -d specifies the data for the QR code, -o specifies the output path. Those are the basics, but you can add other parameters according to the documentation to customize the format or size.
Hi severynm,
I am intrigued by your solution and was wondering if I could speak to you in private about something I am playing with? I am extremely new to VBA and want to combine zint with Excel to produce similar results for different code types as well as ask you some questions about VBA. Hope to hear from you soon!
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi severynm,
I am intrigued by your solution and was wondering if I could speak to you in private about something I am playing with? I am extremely new to VBA and want to combine zint with Excel to produce similar results for different code types as well as ask you some questions about VBA. Hope to hear from you soon!
Welcome to the Board!

Please do not request this, as it is in violation of Rule 4 here (see second paragraph): Message Board Rules

Instead, we invite you to post your question to the public user forums as a new question.
You can tag a specific user by typing a "@" and their username if you have specific reason to alert a specifc user to your question (i.e., if you were tagging me, you would just type @Joe4).
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top