PowerPoint
Barcode objects with VBA

 Standard or higher

Using and automating barcodes with VBA in PowerPoint

With Visual Basic for Applications (VBA), you can easily solve many problems. Here, we briefly show you how to integrate a barcode into a PowerPoint presentation using VBA, how to use it, and how to remove it.

This is how to insert the ActiveBarcode Control into the active slide using VBA:
In this example, the barcode is placed at the specified position and size into the slide. The object can then be addressed via ab:

Dim ab As Shape
Set ab = Application.ActiveWindow.View.Slide.Shapes.AddOLEObject(Left:=100,
  Top:=100, Width:=300, Height:=150, ClassName:="ACTIVEBARCODE.BarcodeCtrl.1")
Now you can change the standard properties (e.g. height, width) of the OLE object using the properties of the variable ab:
ab.Width = 200
ab.Height = 120
Now you can use the properties and methods of the barcode object as you like:
ab.OLEFormat.Object.Type = 6
ab.OLEFormat.Object.Text = "987698769812"
ab.OLEFormat.Object.Rotate = 90
You can easily remove the control from the macro/slide if you no longer need it, for example, after printing:
 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 new.