CodeSoft Programming Using Their ActiveX

Since my search for a code sample using the CodeSoft ActiveX to load a print a label was quite lean on useful examples I decided to write my own. Below you will see C# code which will load a label designed in CodeSoft, fill in the variables included in that label, and then print it to a local printer. The printer, in this case, is a Zebra printer. It could be any printer that is the target for the label layout.

It may be worthwhile to note that the code was originally designed in Visual Studio 2010 (NET4) and it did not work properly. After copying the code into Visual Studio 2008 and NET3.5 it ran quite well and allowed the filling of variables easily. You will see the use of LABELMANAGER2 which is tied to CodeSoft version 9 which is the version used in this instance. This DLL should be referenced in your software. Enjoy …

LabelManager2.Application lblapp = new LabelManager2.Application();

// Open the label

Document doc = lblapp.Documents.Open(@”C:LabelDirName.lab”,true);

// List of variable set up in the label

Variables vars = doc.Variables;

vars.Item(1).Value = “123456”;

vars.Item(2).Value = “12”;

vars.Item(3).Value = “112-542154847″;

vars.Item(4).Value = “This could be a label description”;

vars.Item(6).Value = “Maybe a vendor name”;

vars.Item(7).Value = “Test of a text box”;

// The barcode number is viewed as a plain number and the label program will print the barcode corresponding to the numbers and type selected

vars.Item(8).Value = “123456789”;

doc.Printer.Name = “ZDesigner 140XiIII Plus”;

doc.Format.Portrait = true;

// Print one copy

doc.PrintDocument(1);

// Cleanup code

lblapp.Documents.CloseAll(false);

lblapp.Quit();


People also view

Leave a Reply

Your email address will not be published. Required fields are marked *