Of course you can also convert the function to a UDF to call it from a formula. Then you can draw the barcode with a function like this Sub test() With (X + (CurBar * LineWeight) * XCompRatio, Y, X + (CurBar * LineWeight) * XCompRatio, (Y + Height)).Line LineWeight = MaxWidth / (Len(ContentString) * XmmTopt) The font is downloaded as a ZIP folder to your Downloads. After opening this link, choose Code 39 on the page and click the Download button. If MaxWidth > 0 And Len(ContentString) * LineWeight * XmmTopt > MaxWidth Then You can download Code 39 from several sources. Without it, it will add extra number after a longer digit block.ĬontentString = ContentString + SymbolString(104)įor j = CharIndex To CharIndex + BlockLen(BlockIndex) - 1 Step 1 WeightSum = WeightSum + SymbolIndex * SymbolValue(100) 'switch bĬontentString = ContentString + SymbolString(100)ĬharIndex = CharIndex + 1 'this is a bug fix. If DBlockMod2 0 Then ' switch to B, encode 1 char WeightSum = WeightSum + SymbolIndex * SymbolValue(k) If DBlockMod2 0 Then 'even chars always to encodeĭBlockLen = BlockLen(BlockIndex) - DBlockMod2 ' encoding even amount of chars in a D block WeightSum = WeightSum + SymbolIndex * SymbolValue(99) 'switch cĬontentString = ContentString + SymbolString(99) Select Case IsNumeric(Mid(Content, 1, 1)) WeightSum = WeightSum + i * SymbolValue(k)ĬontentString = ContentString + SymbolString(k)ĬontentString = ContentString + SymbolString(SymbolValue(WeightSum Mod 103))ĬontentString = ContentString + SymbolString(106)ĬontentString = ContentString + Tbar_Symbol If IsNumeric(Content) = True And Len(Content) Mod 2 = 0 Then 'numeric, mode CĬontentString = ContentString + SymbolString(105) ' Supports B and C charsets only values 00-94, 99,101, 103-105 for B, 00-101, 103-105 for Cĭim i, j, k, CharIndex, SymbolIndex As Integerĭim ContentString As String ' bars sequenceĬonst Asw As String * 1 = "A" ' alpha switchĬonst Dsw As String * 1 = "D" 'digital switchĭim BlockIndex, BlockCount, DBlockMod2, DBlockLen As Byteĭim SymbolValue(0 To 106) As Integer ' valuesĭim SymbolString(0 To 106) As String * 11 'bits sequenceĭim SymbolCharB(0 To 106) As String * 1 'Chars in B setĭim SymbolCharC(0 To 106) As String * 2 'Chars in B set Inside VBA IDE select ThisWorkbook and paste the following function Sub Code128Generate_v2(ByVal X As Single, ByVal Y As Single, ByVal Height As Single, ByVal LineWeight As Single, _īyRef TargetSheet As Worksheet, ByVal Content As String, Optional MaxWidth As Single = 0) However yakovleff has posted a great solution in MrExcel forum which will draw the barcode on your sheet, hence no font is needed There's a way to install custom fonts without admin rights
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |