TEC-IT
TECIT
Bookmark Me

FAQ: TBarCode OCX

FAQ TBarCode OCX: Programming, Visual Basic, MS Access, Navision, Visual C++, PHP, Java, Distorted Barcode Output and more...

 

Data Matrix

How to generate an EAN Data Matrix / GS1 Data Matrix?

  • Adjust Data Matrix as symbology
  • Set the Data Matrix format parameter to EAN ( enumeration eDMPr_UCCEAN). This inserts an FNC1 on the first position in the barcode and marks the barcode as GS1/EAN type.
  • Enable Escape Sequences
  • Use the sequence \F to encode an FNC1 separator character between variable length AIs.

Human Readable Text Rotation

Human Readable Text is not Rotated with Barcode

This occurs if the currently selected font does not support rotation. Select a TrueType font to solve the problem (e. g. Arial).

Human Readable Text Font

StdFont OLE object

Change Font in Microsoft Visual Basic, Visual C++, VBscript, PHP

Visual Basic

Dim fnt As stdole.StdFont
Set fnt = new stdole.StdFont
fnt.Name = "Arial"
Set TBC.Font = fnt

Microsoft Visual C++

COleFont cOF = m_TBarCode.GetFont();
tagCY cy = cOF.GetSize();
cOF.SetName("Arial"); // Font Family = Arial
cy.int64 = cy.int64 * 1.5; // add 50% to original size
cOF.SetSize(cy);
m_TBarCode.SetFont((LPDISPATCH) cOF);
cOF.ReleaseDispatch();

VBscript®ASP):

Dim fnt
set fnt = Server.CreateObject("StdFont")
fnt.name = "Arial"
set TBC.Font = fnt

PHP (Windows):

$bcobj = new COM("TBarCode7.TBarCode7");
$fntobj = new COM("StdFont");
$fntobj->Name="Times";
$fntobj->Size=12;
$bcobj->Font=$fntobj;

Human Readable Text Font

How to Change the Font in Navision / Dynamics NAV

You need to generate an Automation Variable of type OLE Automation.StdFont. This font object is then assigned to the TBarCode COM object.

Name      DataType      Subtype
StdFont   Automation    'OLE Automation'.StdFont
    CLEAR(BC);
    BC.Refresh;
    IF ISCLEAR(StdFont) THEN
      CREATE(StdFont);
    StdFont.Size := 30;
    StdFont.Name := 'Arial';
    BC.Font      := StdFont;

Mail Merge Documents with Barcodes

How can I create Mail Merge Documents with Barcodes in Word?

For inserting multiple barcodes you can use the Serial Letter function in the TBarCode Toolbar. This function allows you to replace all marked text passages with barcodes after the mail merge document was created. For more information about the TBarCode Toolbar and its functionality, please refer to the TBarCode OCX User Manual.

If you encounter speed problems you may alternatively use the VBA macro "BarcodeSeries" which can be downloaded in the TBarCode Download Area. The required steps for using the macro are explained in the enclosed text document.

Printing Problems

Distorted Barcode Output (Toshiba TEC, DataMax printers)

This is confirmed to be a printer driver problem. Along other printer models this effect also happens with Toshiba TEC and DataMax printers.

The solution is to change the draw mode of TBarCode:

TBarCode V8+

Set the ActiveX Property DrawMode to Compatible.

TBarCode V7

  1. Create a file barcode.ini with the following content:
  2. [DRAW_MODE]
    UseGDIRect=1
  3. Copy the barcode.ini file to the installation directory of TBarCode (where you can find the file tbarcode7.ocx or tbarcode7.dll).
  4. Restart the program.

Reporting

Bar Codes in Microsoft Access

The common method to print bar codes from within Microsoft® Access is by using a report. The TBarCode Object need only be inserted once at the report definition. Therefore you need a table (query) which servers as data source for the report and a data field, that specifies the content of the bar code.

How to insert TBarCode OCX (as ActiveX Control) in a report?

Open a new report in design view. If you need a bar code for each record, then insert the ActiveX® Control into the detail area and position it at the desired place.

Thereto you choose Insert - ActiveX Control in the main menu. You will see a list of all available elements, from which you select TBarCode.

The control will be inserted in the detail area. The detail area will be printed once for each record set in the table (or query).

How to control the content of the bar code in a report?

In design mode right-click the TBarCode - ActiveX® Control. You will see a menu where you select Properties.

In the field Control Source located in the submenu data you can define the content of the control. That means you can select the table or query field which is encoded as bar code.

Visual Basic

Runtime Error '429': ActiveX component can't create object

You may get this runtime error if you didn't specify the full Prog-ID with CreateObject. Reference the TBarCode Type Lib in the project settings, and use the following commands to create a TBarCode object in VB:

      Dim objTB As TBarCode8
      Set objTB = CreateObject("TBarCode8.TBarCode8")
      objTB.AboutBox

For further trouble shooting read Microsoft Knowledge Base Article - 244264

COM and Java

How can I use your ActiveX Control in JAVA?

ActiveX Controls are COM based so they can be treated as objects. If you have a bridge between Java and ActiveX you can easily integrate TBarCode OCX into your Java projects.

We recommend to try out OLEJA, which is a tool to create Java components from COM components. Here is the link to the product page:

Another possibility is the open source toolkit JAWIN API:

(Please note that TEC-IT can not offer support for third party products).

Barcode Fonts

Why Should I Use TBarCode Instead of a Bar Code Font?

Adjustable PropertyTBarCodeBarcode Font
Adjusting or optimizing the bar width gives you better barcode quality results
Module Width
yesno
Print Ratiofreely scalablemaintain a special height / width ratio
Rotation 0°, 90°, 180°, 270°yesnot always

Product Licensing with Excel

Microsoft Excel - Licensing during Open

Licensing happens during startup of the document which contains the ActiveX®Control.

  • Open the Microsoft VBA editor with Alt+F11
  • In the Project Explorer select This Workbook.
  • Now enter the following code as for the Workbook-Open Event:
Private Sub Workbook_Open()
 Dim tbc As TBarCode8
 Set tbc = CreateObject ("TBarCode8.TBarCode8")
 tbc.LicenseMe "Mem:Licensee", eLicKindDeveloper, 1, "Key", eLicProd1D
 Set tbc = Nothing
End Sub

We recommend to password protect your VBA code in the project property window.

Product Licensing with Access

Microsoft Access - Licensing with Autoexec Macro

Below we show you how to license at startup of the database.

Create a new Module with the following function (in Microsoft VBA Editor):

Public Function LicenseTBarCode()
 Dim TB As New TBarCode8
 TB.LicenseMe "Mem:Licensee", eLicKindDeveloper, 1, "Key", eLicProd1D
 SetTB = Nothing
End Function

Create a new Macro named "Autoexec" with the following settings:

Action = RunCode
Functionname = License TBarCode()
Don't forget to include a reference to the type library of the ActiveX® Control in the menu Tools - References. We recommend to password protect your VBA code in the project property window.

PDF417

How Can I Generate an Optimized PDF417 Bitmap Image?


****** BEGIN SAMPLE CODE ******

Barcode.Barcode = eBC_PDF417
Barcode.Text = "My Data... "

' the following settings produce a barcode 82,296 mm wide
' if your barcode should have a constant width, set the data columns
' as shown below (increase/decrease to make wider/smaller symbol)

Barcode.PDF417.Columns = 15

Dim X, Y
Dim Scaling
Dim Dpi

' define ratio of module width (small bar width) to row height
X = 1
Y = 1       ' keeps default ratio, which is 1:3
'Y = 3 / 2  ' creates 1:5 ratio

Dpi = 300     ' 300 dpi printer
Scaling = 3   ' 1 Module (smallest bar) = 3 Pixels = 0.254mm

Dim Cols
Dim Rows

Cols = Barcode.Get2DXCols()
Rows = Barcode.Get2DXRows()

Dim XSize
Dim YSize

XSize = Int(X * Cols)     
YSize = Int(Y * Rows)   

' scale with DPI enlarging factor
XSize = XSize * Scaling
YSize = YSize * Scaling

' Save barcode as bitmap
Barcode.SaveImage "c:\temp\barcode.bmp", eIMBmp, XSize, YSize, Dpi, Dpi

****** END SAMPLE CODE ******

TEC-IT

© TEC-IT Datenverarbeitung GmbH, Austria  ++43(0)7252/72720  office@tec-it.com