3

Is there a way to create Barcodes (128 standard) on a Mac, preferably via an add-in?

I need it to create barcodes in Excel sheets (or moreso a friend of mine needs it).

I have tried all VBA macros and fonts I found on Google, but none give me a scannable result (usually there are weird characters like ó's mixed in). Does anybody have a working solution?

4
  • From looking at the code definition in en.wikipedia.org/wiki/Code_128 I would assume that a certain amount of scripting (either in Excel or somewhere else) will be required to create correctly-formatted barcodes
    – nohillside
    Aug 18, 2014 at 14:20
  • What's the reasons for that? Aug 18, 2014 at 17:04
  • 2
    Barcode is not a 1:1 translation from a text/number into another notation (which would be required for a simple font replacement to work), see linked wikipedia page for details.
    – nohillside
    Aug 18, 2014 at 19:15
  • At the very bottom of the wikipedia page on Code128, under External Links, you will find.... Free Excel Macro and font for Multiple Barcode 128 Generation. Did you look at that?
    – Vic
    Aug 26, 2014 at 17:08

4 Answers 4

0

You could try the Free Barcode Font downloaded from here: http://www.barcodelink.net/barcode-font.php and install it into /Library/Fonts.

To use it just choose the font** in any Application you want - including Excel.

The barcode will properly need to be in a larger font size then the rest of the cells - but you can try it out your self - maybe it is "good enough" for you.

It is not the best solution - but it is free. Alternatively, you can buy a solution - a search on e.g. Google will give you some hits.

** It is showing a barcode icon, and not the name, but it is located in the C's because the name of the font is code128.ttf

7
0

Here's how I do it:

Column A is the text I want to encode.

Column B is a formula for wrapping that text in asterisks (which is what, for me qualifies the entry as text): =CONCATENATE("*",A2,"*")

The text in column B is formatted with the barcode font, with the size adjusted for legibility, printing, and scanning.

I hope that helps in some way.

ADDENDUM

I found the following macro, authored by Eric Townsend Schmidt. All credit goes to him.

 Public Function code128$(chaine$)
  'This function is governed by the GNU Lesser General Public License (GNU LGPL)
  'V 2.0.0
  'Parameters : a string
  'Return : * a string which give the bar code when it is dispayed with CODE128.TTF font
  '         * an empty string if the supplied parameter is no good
  Dim i%, checksum&, mini%, dummy%, tableB As Boolean
  code128$ = ""
  If Len(chaine$) > 0 Then
  'Check for valid characters
    For i% = 1 To Len(chaine$)
      Select Case Asc(Mid$(chaine$, i%, 1))
      Case 32 To 126, 203
      Case Else
        i% = 0
        Exit For
      End Select
    Next
    'Calculation of the code string with optimized use of tables B and C
    code128$ = ""
    tableB = True
    If i% > 0 Then
      i% = 1 'i% devient l'index sur la chaine / i% become the string index
      Do While i% <= Len(chaine$)
        If tableB Then
          'See if interesting to switch to table C
          'yes for 4 digits at start or end, else if 6 digits
          mini% = IIf(i% = 1 Or i% + 3 = Len(chaine$), 4, 6)
          GoSub testnum
          If mini% < 0 Then 'Choice of table C
            If i% = 1 Then 'Starting with table C
              code128$ = Chr$(205)
            Else 'Switch to table C
              code128$ = code128$ & Chr$(199)
            End If
            tableB = False
          Else
            If i% = 1 Then code128$ = Chr$(204) 'Starting with table B
          End If
        End If
        If Not tableB Then
          'We are on table C, try to process 2 digits
          mini% = 2
          GoSub testnum
          If mini% < 0 Then 'OK for 2 digits, process it
            dummy% = Val(Mid$(chaine$, i%, 2))
            dummy% = IIf(dummy% < 95, dummy% + 32, dummy% + 100)
            code128$ = code128$ & Chr$(dummy%)
            i% = i% + 2
          Else 'We haven't 2 digits, switch to table B
            code128$ = code128$ & Chr$(200)
            tableB = True
          End If
        End If
        If tableB Then
          'Process 1 digit with table B
          code128$ = code128$ & Mid$(chaine$, i%, 1)
          i% = i% + 1
        End If
      Loop
      'Calculation of the checksum
      For i% = 1 To Len(code128$)
        dummy% = Asc(Mid$(code128$, i%, 1))
        dummy% = IIf(dummy% < 127, dummy% - 32, dummy% - 100)
        If i% = 1 Then checksum& = dummy%
        checksum& = (checksum& + (i% - 1) * dummy%) Mod 103
      Next
      'Calculation of the checksum ASCII code
      checksum& = IIf(checksum& < 95, checksum& + 32, checksum& + 100)
      'Add the checksum and the STOP
      code128$ = code128$ & Chr$(checksum&) & Chr$(206)
    End If
  End If
  Exit Function
testnum:
  'if the mini% characters from i% are numeric, then mini%=0
  mini% = mini% - 1
  If i% + mini% <= Len(chaine$) Then
    Do While mini% >= 0
      If Asc(Mid$(chaine$, i% + mini%, 1)) < 48 Or Asc(Mid$(chaine$, i% + mini%, 1)) > 57 Then Exit Do
      mini% = mini% - 1
    Loop
  End If
Return
End Function
1
  • Hi, as discussed in the comments above code128 has to be generated (unlike code39 I believe). Just changing the font will result in non-readable codes (codes that don't represent what has been written). Some type of addin or makro will be necessary. Aug 26, 2014 at 7:00
0

I got the fonts from ID automation Interestingly their VBA scripts only seem to work with their own font.

Another solution (cheaper but more complicated, via AppleScript) that works for a friend of mine is offered here: Scorpion Research

Thanks to everyone for helping out.

0

Thanks Jer-el for the props.

It's true that you can't just download a barcode font and convert a column of data into scannable barcodes. The macro listed above does the trick just fine. I'm moving it to http://etownsendschmidt.com/barcode-generator/3/free-barcode-generator-for-excel

The macro simply looks at the data in 1 column and converts it into the symbols, numbers and letters that corresponds to the font found on dafont.com in another column. I've hidden that column in the file to avoid accidental tampering.

The final column is a copy of that hidden column with the font changed the the barcode font. Click and drag and you're done. I had to barcode 3000 items quickly with no budget. To be completely honest, I found the original non-working code on a french geocities-esque website and it wasn't working since the standard for code128 changed. After fixing it, I tested it with my iPhone barcode scanner and SHAZAM! I cried a little...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .