Word
Barcodes with VBA

VBA Examples

Using and automate barcodes with VBA in Word

1

You can use VisualBasic for Applications (VBA) to solve many things in Word. Here we will show you how to embed, use and delete the ActiveBarcode control with VBA:

Embedding the ActiveBarcode Control into a document:
In this example a barcode control will be placed at the cursors position. Then you can modify the object using the variable 'ab':

Dim ab As Object
Set ab = Selection.InlineShapes.AddOLEObject(ClassType:="BARCODE.BarcodeCtrl.1",
FileName:="", LinkToFile:=False, DisplayAsIcon:=False)
Set the standard properties (height, width) of the object using the variable 'ab':
ab.Width = 200
ab.Height = 120
You can access the properties and methods of the barcode object by using the property "OLEFormat.Object":
ab.OLEFormat.Object.Type = 6
ab.OLEFormat.Object.Text = "987698769812"
You also can use a more cleaner way to access the properties by creating and using a variable, e.g. named 'abObject':
Dim abObject As Object
With ab.OLEFormat
.Activate
Set abObject = .Object
End With

abObject.Type = 6
abObject.Text = "987698769812"
Using the following call you can cast the barcode object in an InlineShape. Note, however, that you can change the barcode no longer after the conversion.
ab.ConvertToShape
If you do not need the control anymore you can delete it from the document:
 ab.Delete
Hint: If it's necessary that Windows process upcoming events (often named as "KeepWindowsAlive") within a macro, you can force this by using the following VBA function:
DoEvents
This can be necessary, e.g. if the Control must draw itself anew.


| Home | Shop | Download | E-Mail | Privacy Policy | Imprint | Version 6.5.0
Copyright ©
Frank HornActiveBarcode Generator
Web design: szBubble 3.1.12.318
Copyright © Frank Horn
&
Lars SchenkActiveBarcode Object
Web- & server component
Command line
Copyright © Lars Schenk

All trademarks and product names mentioned are the property of their respective owners.



We use cookies to provide you with the best experience and functionality on our website. By using our site you agree to this. read more >