I need to add a logo to a vCard QR code using VBA, how can I do that?

Chris Mathis 1 Reputation point
2023-05-23T12:05:25.9666667+00:00

I have the following VBA code to create a vCard QR Code, but need to add an image on the QR code and not finding anything that shows me how to do that. Any help?

Sub generateQRCode()

    strURL = "https://chart.googleapis.com/chart?cht=qr"

    For intRow = 2 To 5

        strFname = Trim(ThisWorkbook.Sheets("Contact_Info").Range("A" & intRow).Text)
        strLname = Trim(ThisWorkbook.Sheets("Contact_Info").Range("B" & intRow).Text)
        strEmail = Trim(ThisWorkbook.Sheets("Contact_Info").Range("C" & intRow).Text)
        strCompn = Trim(ThisWorkbook.Sheets("Contact_Info").Range("D" & intRow).Text)

        strVCF = ""
        strVCF = strVCF & "BEGIN:VCARD" & Chr(10)
        strVCF = strVCF & "VERSION:3.0" & Chr(10)

        strVCF = strVCF & "N:" & strLname & ";" & strFname & Chr(10)
        strVCF = strVCF & "ORG:" & strCompn & Chr(10)
        strVCF = strVCF & "FN:" & strFname & Chr(10)

        strVCF = strVCF & "EMAIL:" & strEmail & Chr(10)

        strVCF = strVCF & "END:VCARD"

        ThisWorkbook.Sheets("Contact_Info").Range("I" & intRow) = strVCF
        
        strChs = "&chs=174" & "x" & "174"
        strCh1 = "&chl="
        strFinalURL = strURL & strChs & strCh1 & strVCF
        
        Dim pic As Object, sh As Shape
        ActiveSheet.Range("J" & intRow).Select

        Set pic = ActiveSheet.Pictures.Insert(strFinalURL)
        pic.Top = ActiveSheet.Range("J" & intRow).Top
        pic.Left = ActiveSheet.Range("J" & intRow).Left

    Next


End Sub
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,531 questions
0 comments No comments
{count} votes