New User? Sign Up  |  Sign In  |  Help
Barcode support and
tutorials from IDAutomation
and the community.
Click for the BBB Business Review of this Computers Hardware, Software & Services in Tampa FL
Resolved Questions

How to encode Data Matrix Barcodes using VBA in Excel?

The tutorial explains how to encode data in Excel using the Data Matrix Font Encoder VBA.

The Data Matrix Font Encoder VBA is included in:

Data Matrix Font and Encoder Package

Universal 2D Font Package

NOTE:
IDAutomation offers a 2D Font for Excel; however, it does have some limitations. It is compatible with Data Matrix, QR Code, PDF417, and Aztec. Microsoft Excel may also be used as a data source for the font, as explained below.

image

Operating System: Windows

Application: Excel

09-26-13     11.1 year(s) ago    

  Report Abuse

 

Ben

Best Answer

NOTE: A new product is now available since this issue was resolved that offers a better way to generate barcodes in Excel on Windows and Mac, the IDAutomation Native Generator for Excel.


Tutorial Updated 10/28/2021

1. Download and install a font package that includes Data Matrix. The package installs the necessary encoders. To generate barcodes directly in Excel, download and install the IDAutomation 2D XLS Font



2. Open Excel and set up the spreadsheet. In the example, data in column A2 will include the data to convert to the barcode. A formula will be written in B2 to produce the encoded data.

image



3. Minimize Excel and locate the VBA file named IDAutomation_VBA_DataMatrix_FE2021.bas or (IDAutomation_Datamatrix_Macro.bas--Demo verison). The VBA is located in the Integration folder of the product download.
image


4. Maximize Excel and select the Developer Tab.
Microsoft Support - Enable Developer Tab

image



5. Select Visual Basic to enter the Editor.
image



6. To import the VBA file, select File -- Import File then search for and select the .bas file.

image



7. NOTE: If using the demo file (IDAutomation_Datamatrix_Macro.bas), you must complete this step. Otherwise, skip to step 8. Select Tools -- References and search for the Data Matrix encoder. Choose OK.
image



8. Select File and choose Close and Return to Microsoft Excel.
image



9. In cell B2, enter the formula:
Licensed Version use: =IDAutomation_DMatrix_FontEncoder()
Demo Version, use: =EncDM()

and reference cell A2 to encode the data.
image

The encoded data displays several uppercase alpha characters.

===================================================
To generate GS1 Data Matrix

=SUBSTITUTE(EncDM(A2,1,0,0), CHAR(13),"")
=SUBSTITUTE(IDAutomation_DMatrix_FontEncoder(A2,1,0,0), CHAR(13),"")

Setting the second parameter to 1 enabled ApplyTilde which allows you to insert ~1 before any Application Identifier (AI). Here is an example of A2 for GS1-Data Matrix:

(01)3456789012345 must be entered as ~1013456789012345

image

or using the Substitute function:
image

===================================================


10. Save the file.


HOW TO DISPLAY SCANNABLE 2D BARCODES IN EXCEL


GENERATE BARCODE IN EXCEL

(1) Apply the IDAutomation2D XLS font.

(2) Right-click the column and choose Format Cells.
image

(3) Select the Alignment tab and then check Wrap text.
image



HOW TO MAIL MERGE
To generate the barcode the encoded file must be used in a mail merge/data merge. Video Example of 2D mail merge. The only difference between the video and this tutorial is that the video uses the Barcode Add-In encoder and Data Matrix. Begin the video at 2:35.
Video Example

CARRIAGE RETURN ERROR
After merging the data into Word, a group of characters, such as _x000D_ or barcode
image, may appear at the end of the merged data. To resolve the issue, return to Excel and implement the SUBSTITUTE function.

Example:

=SUBSTITUTE(EncDM(A2), CHAR(13),"")

Posted 11.1 year(s) ago

(0)
(0)
  Report Abuse
 
Find Interesting
 
Email to Others
 
Bookmark
 
Subscribe to Answer Alert
No comments yet.     Be the first to comment.

Email this question link to friends
You must enter an email address, if name is entered or vice-versa for each friend.
Friend #1 -
Friend #2 -
Friend #3 -
Friend #4 -
Friend #5 -
  Your comment on this question
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must starts with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always starts with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 Characters are allowed. Current Count: 0
  Your comment on this answer
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allow you to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must start with "http://" or "https://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always start with "http://" or "https://")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 characters are allowed. Current Count: 0

You may answer and comment on any thread according to the Terms and Conditions.

 © Copyright 2021 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook