Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using QRCodegenBarcode as UDF in excel VBA #2

Open
YasserKhalilExcelEgy opened this issue Feb 4, 2023 · 13 comments
Open

Using QRCodegenBarcode as UDF in excel VBA #2

YasserKhalilExcelEgy opened this issue Feb 4, 2023 · 13 comments

Comments

@YasserKhalilExcelEgy
Copy link

Thank you very much for your efforts.
I have tried to use this function QRCodegenBarcode as UDF in cell B2 but what I got is just numbers and not a barcode.
The code is working well on userform not on worksheet. Any ideas?

@landv
Copy link

landv commented Feb 7, 2023

Image0.PictureData = QRCodegenConvertToData(QRCodegenBarcode("Sample text"), 500, 500)

@YasserKhalilExcelEgy
Copy link
Author

Thanks a lot. I am using excel VBA not access. Is it possible to use as UDF (user-defined function) in excel VBA?

@landv
Copy link

landv commented Feb 7, 2023

vbaGenerateQRcode.xls
https://github.com/landv/vba
you can use this libary
Some functions are in Chinese. Please use the translator to translate.

@YasserKhalilExcelEgy
Copy link
Author

Thank you very much. I couldn't deal with it as the file has chinese characters and I encountered errors when trying to execute the codes on it. Can you modify your base module to make it available to create the qrcode in cells?

@landv
Copy link

landv commented Feb 7, 2023

I'll delete Chinese and replace it with English tomorrow.
You can generate pictures in batches to the clipboard and paste them into the table by clicking the button.

You can also use the plug-in that comes with Office and click the development tool - Insert - (bottom right corner) other controls - Microsoft Barcode Control.

@YasserKhalilExcelEgy
Copy link
Author

Thank you very much. I appreciate a lot your help.

@landv
Copy link

landv commented Feb 7, 2023

Thank you very much. I appreciate a lot your help.

https://youtu.be/8xD8Fn6qsgw
This video uses Microsoft Barcode Control to generate dynamic QR codes.

@wqweto
Copy link
Owner

wqweto commented Feb 8, 2023

Here is some sample code you can place in a module in Excel and call Test_CreateBarCodes

Option Explicit

Private Sub Test_CreateBarCodes()
    InsertBarCode "A18", "H14"
    InsertBarCode "A19", "R14"
End Sub

Private Sub InsertBarCode(sCellSource As String, sCellDestination As String)
    Dim CellSrc     As Excel.Range
    Dim CellDst     As Excel.Range
    Dim TempFile    As String
    
    Set CellSrc = ActiveSheet.Range(sCellSource)
    Set CellDst = ActiveSheet.Range(sCellDestination)
    TempFile = Environ$("TEMP") & "\qrcode.emf"
    SavePicture QRCodegenBarcode(CellSrc.Value), TempFile
    ActiveSheet.Shapes.AddPicture TempFile, msoFalse, msoTrue, CellDst.Left, CellDst.Top, CellDst.Width, CellDst.Height
    Kill TempFile
End Sub

@amjorge1972
Copy link

Thanks a lot. Using in MS Access.

@amjorge1972
Copy link

When printing, it is taking too long. Almost 10 secs each print page.

@wqweto
Copy link
Owner

wqweto commented Mar 6, 2023

Did you try using Microsoft Barcode Control instead?

@amjorge1972
Copy link

No. How ? Where I can find it?

@amjorge1972
Copy link

Solved. Thanks!

ActiveX / OCX controls download:
https://download.extendoffice.com/downloads/other/Controls/MSBCODE.zip

Excel instalation:
https://de.extendoffice.com/documents/excel/5404-excel-create-qr-code.html

MS Access use:
https://www.activebarcode.com/howto/access-barcode-object-report

Works fine realtime data linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants