织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

欧博娱乐VBA code for generating QR codes, but where do

时间:2025-07-18 00:00来源: 作者:admin 点击: 0 次
For work, I have to generate some QR code with info in it. Therefore, I checked on internet and found this "already made" QR code generator : https:/

For work, I have to generate some QR code with info in it. Therefore, I checked on internet and found this "already made" QR code generator :

https://github.com/JonasHeidelberg/barcode-vba-macro-only

It's very nice, and works quite well.

I'm trying to integrate it into my VBA sheet to do data treatment before using the code to create the final QR code. (Nothing complex)

here is how it looks like :

enter image description here

The 4 cells "B4 to B6" get the entry data which are encoded or not, depending on the checkboxes, then the result it written in the column D. Each cell content is stacked in a variable, and this variable is given to eat to the QR code generator :

Public Function GenerateQRCode() Dim CurrentWS As String UserDataRange = "B6:B9" 'The cells in which the data to be encoded are stored InputDataRange = "D6:D9" 'the cells with the encoded (or not) values InputCell = "A4" 'the cell where the text to be encoded in the QR code has to be put 'encode the text depending on hte value of the cell behind the chek boxes For Each cell In Range(UserDataRange) If cell.Offset(0, 1) = True Then EncodedText = EncodeDecode.Base64EncodeString(cell.Value) cell.Offset(0, 2).Value = EncodedText ElseIf cell.Offset(0, 1) = False Then cell.Offset(0, 2).Value = cell.Value End If Next Range(InputCell).ClearContents DataToEncode = "" 'puts the text in the input line with dashes between each value For Each cell In Range(InputDataRange) pouet = Range(InputDataRange).Address If DataToEncode = "" Then DataToEncode = cell.Value & Chr(10) Else If cell.Address = Mid(Range(InputDataRange).Address, InStr(1, Range(InputDataRange).Address, ":") + 1, _ Len(Range(InputDataRange).Address) - (InStr(1, Range(InputDataRange).Address, ":") - 1)) Then DataToEncode = DataToEncode & cell.Value Else DataToEncode = DataToEncode & cell.Value & Chr(10) End If End If Next Range(InputCell).Value = DataToEncode End Function

My concern is that "whatever cell I modify in the whole workbook, it lunches the QR code generator."

I wanted to give a condition at the beginning of the code like If cell A4 is modified, lunch the code, but I don't even achieve to understand what makes the code start and how the data are gathered...

My best guess is that this is the beginning of the code :

Public Function EncodeBarcode(ShIx As Integer, xAddr As String, _ code As String, pbctype%, Optional pgraficky%, _ Optional pparams%, Optional pzones%) As String Dim s$, bctype%, graficky%, params%, zones% Dim oo As Object Call Init If IsMissing(pzones) Then zones = 2 Else zones = pzones If IsMissing(pparams) Then params = 0 Else params = pparams If IsMissing(pgraficky) Then graficky = 1 Else graficky = pgraficky If IsMissing(pbctype) Then bctype = 0 Else bctype = pbctype

But how is it started? O.o

I thought a line like Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, cancel As Boolean) followed by a control of the value of "target" was mandatory... Here, it looks like magic to me :(

How does xAddr gets the address of the cell I clicked? Magic again...

I would like the execution of the code to happen only when I click the button I created. (it generate some infinite loops and excel shuts down :/ ) Or, if not possible, I would like it to be executed only when the data in the cell A4 are modified.

Thank's for your help :)

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-07-18 07:07 最后登录:2025-07-18 07:07
栏目列表
推荐内容