Skip to content

Instantly share code, notes, and snippets.

@hoajb
Created February 20, 2020 08:58
Show Gist options
  • Save hoajb/4bbf159c13569d04035196e98f7a1745 to your computer and use it in GitHub Desktop.
Save hoajb/4bbf159c13569d04035196e98f7a1745 to your computer and use it in GitHub Desktop.
WarSyndrome
4 months ago
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, MyArray
Dim Invalid: Invalid = "\/:*?" & """" & "<>|"
For Each val In Selection
Name = val.Value
MyArray = Split(Name, ",", -1, 1)
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 & Application.PathSeparator & MyArray(0) & ".png", 2 '//overwrite
.Close
End With
Next
End Sub
@Paupau-1712
Copy link

I just want to ask if How will I put a label on the imag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment