|
From: Massimo P. <mas...@gm...> - 2016-04-23 13:51:16
|
Hello,
first of all THANKS for this tool, is fantastic.
I need to generate a barcode concatenating a certain nr of excel cells
separated by TAB character.
It's all OK but when I have a space inside a cell, encoding process stops
and I don't understand why.
When I enter manually the string n the frontend, I' don't have problem so I
think is a problem due to how excel represent characters.
Below you can find macro code, as you can note there's nothing special.
Thanks for support
Massimo Pini
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
LongPtr)
Function BarCode(GearNr As String, GearType As String, SerialNr As String,
PartNr As String)
Dim strZintFolder As String
Dim strZintCall As String
Dim strZintOutputFolder As String
Dim strZintOutputFile As String
Dim strZintFinalString As String
Dim intZintFormat As Integer
Dim intQRvers As Integer
Dim intErrorCorrection As Integer
Dim strZintCodeData As String
Dim sep As String
Dim FileToDelete As String
Dim strZintBarcodeHeight As Integer
sep = "\t"
strZintCodeData = GearNr & sep & GearType & sep & SerialNr & sep & PartNr
strZintCodeData = Replace(strZintCodeData, " ", Chr$(32)) 'Data to encode
strZintFolder = "C:\Program Files (x86)\Zint\" 'Folder where
zint.exe can be found
strZintCall = "zint.exe" 'executable filename.
Should be zint.exe
intZintFormat = 20 '20 Selecting which type
of barcode you wish to produce (
http://www.zint.org.uk/zintSite/Manual.aspx?page=3)
strZintOutputFolder = "C:\Users\Asus-pc\Desktop\" 'Folder where
you want the files put
strZintOutputFile = "Code" 'PNG Filename
strZintBarcodeHeight = "12"
strZintFinalString = strZintFolder & strZintCall & " -b " & intZintFormat
& " -o " & strZintOutputFolder & strZintOutputFile & ".png" & " --height "
& strZintBarcodeHeight & " -d " & strZintCodeData & ""
Call Shell(strZintFinalString, 0)
Sleep (100)
Set p = ActiveSheet.Pictures.Insert(strZintOutputFolder & strZintOutputFile
& ".png")
With p
.Left = Range("E1").Left
.Top = Range("E1").Top
.Placement = 1
.PrintObject = 1
End With
FileToDelete = strZintOutputFolder & strZintOutputFile & ".png"
Kill (FileToDelete)
End Function
|