Created
February 20, 2020 08:58
-
-
Save hoajb/4bbf159c13569d04035196e98f7a1745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just want to ask if How will I put a label on the imag