Table of Contents
This section explains the steps to add DataMatrix barcodes in a Microsoft Access report using Morovia DataMatrix ActiveX Control.
The DataMatrix ActiveX control must be installed and registered on the computer.
Open a report in design view and choose Insert ActiveX Control button.
→ . If you are using Access 2007 or 2010, switch to Design view, and click onFrom the list of controls, select
Morovia DataMatrixControl
.After the control is placed on the report, right click on it and choose
Modify the Control Source property to point to the table and field of the data you wish to encode into the barcode. The data source can be a table field, or a field of a comprehensive query result.
Modify other properties, such as
ModuleWidth
, andSizeID
. After you are satisfied with the result, close the property dialog.Save the run the report. You should see the barcodes appear in the report.
You can also add DataMatrix barcodes to Access report using font-based solution.
Before creating barcodes in Microsoft Access, you must import the required module. This module adds VBA function so that you can put into the report. Choose
→ and selectMorovia.DataMatrixFontDLL5.bas
file, located in the program folder.Open a report in design view and add a text box to the report. The text box will be modified to contain a barcode.
Right click on the text box and choose properties.
Place the formula
=DataMatrixEncode([TestData.Data],-1)
in the control source property of the text box where [TestData.data] is the field that contains the data to be encoded into the DataMatrix barcode. The following parameter is the size ID desired.Run the report. You should see lines of hexadecimal characters appear in the place of the text box. This is the barcode string in the raw text form.
Go back to the design view and change the font of the text box. In our case, choose
MRV DataMatrix5
and 6 points. Adjust the size of the text box to fit the whole barcode.Save and run your report. You should see the barcodes appear in the report.
Excel has line gap issues with DataMatrix fonts. You can paste EMF image from GUI encoder, or use ActiveX control as outlined below.
After you finished other parts of the spreadsheet, choose
→ →When Control Toolbox appears, click on button.
On Excel 2007 and 2010, first switch to developer tab, then press Insert button on the toolbar, and select More Controls button.
From the list of controls presented, choose Morovia DataMatrixControl.
Select the area to place the control in the spreadsheet.
Right click on the control, choose Properties and change the Linked Cell property to the name of the cell that contains the data you wish to encode.
Change other properties as necessary such as
Rows
,Cols
andAspectRatio
to adjust the size of the barcode.After editing the properties, click on
button to exit design mode. The barcode will appear in the spreadsheet.The barcode is now bound to the cell. Change the data of the linked cell, the barcode will change accordingly.
Note: to subsequently modify or delete the barcode control, Excel must enter
Design Mode
. This can be done by pressing the button on the Control Toolbox.
Using Datamatrix control in Microsoft Word is similar to the one in Excel, except that Word does not provide a way for data binding.
choose
→ → .In the toolbox, choose the
button.Select Morovia DataMatrixControl from the list of available ActiveX controls. After selecting it, the control will appear in the document, the control may be sized as necessary. To change the properties of the control right click on the control and choose Properties.
When finished, exit the design mode by choosing the
button.To edit the properties of the control the program must be in design mode. If there are problems editing the properties of the control, press the
button to enable it.
This tutorial uses Excel file Word Mail Merge DataSource.xls
as mail merge data source. The data looks like this:
We want to print address information as well as a DataMatrix barcode that encodes such information in Avery label paper 5163. The Print Preview looks like the one below:
Before we start, we need to import a module into Excel. To do that, open Visual Basic Editor. In Excel 2007, this is done by selecting → .
In Visual Basic Editor, choose → . Navigate to the DataMatrix Fonts & Encoder 5 installation folder, and select the
Morovia.DataMatrixFontDLL5.bas
.Close Visual Basic Editor.
Add a new column in the spreadsheet that will hold the barcode string. In our case, we use column H. In cell H2, enter the definition as below:
After hitting Enter, you should see a hexadecimal string result show up. If not, examine the formula you entered.
Note the use of Excel function
CONCATENATE
here. This function is used to combine several fields, as well as line return characters.See the DLL API for the meaning of each field. Here we set size ID to -1.
Copy the formula to other cells of the same column. This can be done by selecting cell H2, highlighting the cells that the formula is copied, and select Paste.
Close the Excel file and start Microsoft Word.
In Microsoft Word, choose Avery 5163 as the label we will work on.
→ → . SelectSelect Select Table, choose Sheet1$.
. In the file dialog, navigate to the spreadsheet we just created. If it asks forClick on
. This is for the address line. Microsoft Word has the intelligence to select the address block.Hit Enter once to move the cursor below, and click on . Select Barcode as the merge field.
Click on
. You should see the first record show up, with hexadecimal characters in the place of barcode.Now adjust the font for the address block and the barcode field. For the address block, we use Arial 16 points. For the barcode, use
MRV DataMatrix5
6 points.Copy the format to other labels by selecting Update labels.
Select
to view the sheets of labels.