Tham khảo code sưu tầm trên mạng.Các anh chị nào có Add in tao QR code miễn phí cho em xin với.
Sub CRQRCODE(ByVal xContent As String, ByVal SheetName As String, ByVal xAddress As Range)
With Documents.Add
.Fields.Add(Range:=.Range, Type:=-1, Text:="Displaybarcode""" & xContent & """ QR", PreserveFormatting:=True).Cut
.Shapes.AddShape(msoShapeRectangle, 2, 2, 2, 2).Select
.Shapes(1).Fill.Visible = msoFalse
.Shapes(1).TextFrame.TextRange.Paste
.Shapes(1).TextFrame.AutoSize = True
.Shapes(1).Height = .Shapes(1).Height - 10
.Shapes(1).Width = .Shapes(1).Height + 8
.Shapes(1).Line.Visible = msoFalse
.Shapes(1).Select
.Application.Selection.Copy
.Close False
End With
ThisWorkbook.Sheets(SheetName).Pictures.Paste.Select
With Selection
If CheckErPic(SheetName, xAddress.Address) = True Then
Sheets(SheetName).Shapes(xAddress.Address).Delete
End If
.Name = xAddress.Address
ThisWorkbook.Sheets(SheetName).Activate
If xAddress.Width > xAddress.Height Then
.Height = xAddress.Height
.Left = xAddress.Left + (xAddress.Width - xAddress.Height) / 2 - 5
.Top = xAddress.Top
Else
.Top = xAddress.Top + (xAddress.Height - xAddress.Width) / 2 + 4
.Left = xAddress.Left
.Width = xAddress.Width
End If
End With
End Sub
Sub RunCrQR()
Dim i As Integer
i = 4
With ActiveSheet
Do While .Cells(i, 1) <> ""
CRQRCODE .Cells(i, 2).Value, .Name, .Cells(i, 4)
i = i + 1
Loop
End With
End Sub
Function CheckErPic(ByVal SheetName As String, ByVal xNamePic As String) As Boolean
Dim pic As Shape
On Error GoTo sai
Set pic = Sheets(SheetName).Shapes(xNamePic)
CheckErPic = True
Exit Function
sai:
CheckErPic = False
End Function
Public Function QREncode(ByVal text As String, _
Optional ByVal width! = 80, _
Optional ByVal height! = 80, _
Optional ByVal ecLevel As ErrorCorrectionLevel = ErrorCorrectionLevel.H, _
Optional ByVal charsetName As String = "Shift_JIS") As Variant
Tham khảo code sưu tầm trên mạng.
Code tạo mã QRcode này chạy mà không cần có mạng.
Static AW As Object
If AW Is Nothing Then Set AW = CreateObject("Word.Application")
With AW.Documents
End With
Bạn gỡ gì đó vào cột A,/Sh Active. và chạy sub RunCrQR. để được kết quả.Chạy nó làm sao Anh @HUONGHCKT ????
(Add-in đó có nguồn gốc từ Nhật) QR Code cũng do 1 người Nhật sáng kiến và tạo ra=QREncode(C2 & char(10) & I2 & char(10) & J2 & char(10) & H2, 100,100)
Sub addQR()
'On Error Resume Next
'format=svg/png/jpg, bgcolor=RGB, https://goqr.me/api/doc/create-qr-code/ http://api.qrserver.com/v1/create-qr-code/?format=png&ecc=H&margin=5&bgcolor=255-255-255&data=
Application.ScreenUpdating = 1
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
For Each i In Selection
If i <> "" Then
pic = "https://api.qrserver.com/v1/create-qr-code/?format=png&size=350x350&data=" & i.Value
If i.Comment Is Nothing Then i.AddComment
i.Comment.Text vbLf
With i.Comment.Shape
.Left = ActiveCell.Left: .Top = ActiveCell.Top:
.Visible = False
.Width = 250: .Height = 250
.Fill.UserPicture pic
End With
End If
Next
Application.ScreenUpdating = 1
Application.EnableEvents = 1
Application.Calculation = xlCalculationAutomatic
End Sub