How can I create QR Code from multiple Excel cells

Viewed 925

All I am looking for the code in VB to generate the QR code. The data is text in first 20 rows and only 1 column A. I want to generate QR code that will contain the serial numbers recorded in 20 cells. I have found the following code but this generate the QR code for each cell entry and save it to the location. But I am looking for one QR code for 20 cells. Currently I have to copy data manually and then paste in any web QR generator and download the PNG file. I want to automate it so I don't have to go to website every time and generate the QR.

code i have used is.

Sub InsertQR()

          Dim xHttp: Set xHttp = CreateObject("Microsoft.XMLHTTP")
          Dim bStrm: Set bStrm = CreateObject("Adodb.Stream")
          Dim size: size = 500 'dalam Pixels
          Dim QR, Name, val
          Dim Invalid: Invalid = "\/:*?" & """" & "<>|"
          For Each val In Selection
        Name = val.Value
        For intChar = 1 To Len(Name)
            If InStr(Invalid, LCase(Mid(Name, intChar, 1))) > 0 Then
                MsgBox "The file: " & vbCrLf & """" & Name & """" & vbCrLf & vbCrLf & " is invalid!"
                Exit Sub
            End If
        Next
        QR = "http://chart.googleapis.com/chart?chs=" & size & "x" & size & "&cht=qr&chl=" & Name
        xHttp.Open "GET", QR, False
        xHttp.Send
        With bStrm
            .Type = 1 '//binary
            .Open
            .write xHttp.responseBody
            .savetofile ThisWorkbook.Path & "\" & Name & ".png", 2 '//overwrite
            .Close
        End With
    Next
End Sub

Everyone's help is really appreciated.

0 Answers
Related