Home > Topics > excel > body text

How to generate QR code in excel

DDD
Release: 2023-08-18 11:38:23
Original
15097 people have browsed it

How to generate QR code in excel: 1. Use VBA macro to generate QR code, open the VBA editor, click the "Insert" menu, select "Module", enter the VBA code in the new module, and click Run, execute the VBA macro, and select the cell range to generate the QR code; 2. The third-party plug-in generates the QR code, click the "File" menu, select "Options", in the dialog box, select "Add-ins", Open the COM add-in dialog box, select the QR code plug-in file to be installed, install the plug-in, select the cell to generate the QR code, and generate the QR code.

How to generate QR code in excel

Excel is a powerful spreadsheet software that can not only perform data analysis and calculations, but also chart making and data visualization. Although Excel itself does not directly support generating QR codes, we can use some plug-ins or macros to achieve the function of generating QR codes in Excel.

Below I will introduce two commonly used methods to generate QR codes.

Method 1: Use VBA macro to generate QR code

Step 1: Open Excel and press the "Alt F11" key combination to open the VBA editor.

Step 2: In the VBA editor, click the "Insert" menu and select "Module".

Step 3: In the newly created module, enter the following VBA code:

Sub GenerateQRCode()
    Dim qrCode As Object
    Dim rangeToEncode As Range
    Dim cell As Range
    
    ' 设置二维码生成器对象
    Set qrCode = CreateObject("WScript.Shell")
    
    ' 获取要生成二维码的单元格范围
    Set rangeToEncode = Application.InputBox("请选择要生成二维码的单元格范围:", Type:=8)
    
    ' 循环生成二维码
    For Each cell In rangeToEncode
        ' 调用二维码生成器生成二维码图片
        qrCode.Run "cmd /c qrencode -o " & cell.Address & ".png " & cell.Value
        
        ' 将生成的二维码图片插入到单元格中
        cell.Select
        ActiveSheet.Pictures.Insert(cell.Address & ".png").Select
        Selection.ShapeRange.LockAspectRatio = msoFalse
        Selection.ShapeRange.Height = cell.RowHeight
        Selection.ShapeRange.Width = cell.Width
        Selection.ShapeRange.Top = cell.Top
        Selection.ShapeRange.Left = cell.Left
        Selection.ShapeRange.Placement = xlMoveAndSize
        
        ' 删除生成的二维码图片
        Kill cell.Address & ".png"
    Next cell
    
    ' 清理对象
    Set qrCode = Nothing
End Sub
Copy after login

Step 4: Press the "F5" key or click the Run button to execute the VBA macro. A dialog box will pop up, please select the cell range to generate QR codes.

Step 5: After waiting for a period of time, Excel will generate the corresponding QR code in the selected cell.

Method 2: Use a third-party plug-in to generate a QR code

Step 1: Open Excel, click the "File" menu, and select "Options".

Step 2: In the Excel Options dialog box, select "Add-ins".

Step 3: Click the "Go" button to open the COM add-in dialog box.

Step 4: Click the "Browse" button and select the QR code plug-in file to be installed.

Step 5: Click the "OK" button to install the plug-in.

Step 6: In Excel, select the cells where you want to generate QR codes.

Step 7: Click the "Plug-in" menu, select the QR code plug-in, and generate the QR code.

Summary:

Through the above two methods, we can generate QR codes in Excel. The method of using VBA macro requires certain programming knowledge, but the style and position of the generated QR code can be customized. The method of using third-party plug-ins is simpler, but may be limited by the functions and settings of the plug-in. Choose the appropriate method to generate QR codes based on personal needs and actual conditions.

The above is the detailed content of How to generate QR code in excel. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template