-
-
Save ndthanh/981e4c6d6cdc8044813b95beb7f89938 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
Sub INSERT_QRCODE() | |
Const BarcodeWidth As Integer = 156 | |
Dim ws As Worksheet, WdApp | |
Set ws = ActiveSheet | |
Set WdApp = CreateObject("Word.Application") | |
With WdApp.Documents.Add | |
.PageSetup.RightMargin = .PageSetup.PageWidth - .PageSetup.LeftMargin - BarcodeWidth | |
'.Fields.Add(Range:=.Range, Type:=-1, Text:="DISPLAYBARCODE " & CStr(Selection.Value) & " CODE39 \d \t", PreserveFormatting:=False).Copy | |
.Fields.Add(Range:=.Range, Type:=-1, Text:="DISPLAYBARCODE " & CStr(Selection.Value) & " QR \q 3", PreserveFormatting:=False).Copy | |
End With | |
ws.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False, DisplayAsIcon:=False | |
WdApp.Quit SaveChanges:=False | |
Set WdApp = Nothing | |
End Sub | |
Sub INSERT_BARCODE() | |
Const BarcodeWidth As Integer = 156 | |
Dim ws As Worksheet, WdApp | |
Set ws = ActiveSheet | |
Set WdApp = CreateObject("Word.Application") | |
With WdApp.Documents.Add | |
.PageSetup.RightMargin = .PageSetup.PageWidth - .PageSetup.LeftMargin - BarcodeWidth | |
.Fields.Add(Range:=.Range, Type:=-1, Text:="DISPLAYBARCODE " & CStr(Selection.Value) & " CODE39 \d \t", PreserveFormatting:=False).Copy | |
'.Fields.Add(Range:=.Range, Type:=-1, Text:="DISPLAYBARCODE " & CStr(Selection.Value) & " QR \q 3", PreserveFormatting:=False).Copy | |
End With | |
ws.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False, DisplayAsIcon:=False | |
WdApp.Quit SaveChanges:=False | |
Set WdApp = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment