Professional Documents
Culture Documents
vote I found Sbastien Ferry's comment to be the working solution for your question. It's a
pure VBA 1D/2D code generator created by Jiri Gabriel under MIT License in 2013.
I had to do some modification and translation of some of the comments to understand
how it works.
To use it in a worksheet, just copy or import barcody.bas into your VBA in a module
from Google code. In a worksheet, just put in the function like this:
=EncodeBarcode(CELL("SHEET"),CELL("ADDRESS"),A2,51,1,0,2)
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
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?
The code could be modified more to make it a pure VBA function call rather than
using it as a formula in a worksheet. You can add the following code to the end of the
barcody.bas
Public Sub RenderQRCode(workSheetName As String, cellLocation As
String, textValue As String)
Dim s_param As String
Dim s_encoded As String
Dim xSheet As Worksheet
Dim QRShapeName As String
Dim QRLabelName As String
s_param = "mode=Q"
s_encoded = qr_gen(textValue, s_param)
Call DrawQRCode(s_encoded, workSheetName, cellLocation)
With the modification, you can now simply call to render QRCode by calling this in
VBA:
Call modQR.RenderQRCode("Sheet1", "A13", "QR Value")
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
With xSheet.Shapes(QRShapeName)
.Width = 30 'change your size
.Height = 30 'change your size
End With