This sample demonstrates how to change the label engine of all data frames in a map document to Maplex programmatically. Upon changing the data frame label engine, the labeling properties or all layers in the Data Frame are translated to Maplex labeling properties automatically. The Maplex extension should be enabled in the Extensions dialog in ArcMap before running this code.
How to use
- Copy and paste the sample code into the VBA Editor.
- Run the Macro.
Public Sub ChangeMxDocumentLabelEngine()
'This simple subroutine will change the label engine for all data frames in a map to be the maplex label engine
'You should have a maplex license enabled before running this code
Dim pMxDoc As IMxDocument
Dim pMaps As IMaps
Dim pMap As IMap
Dim index As Long
Dim pAnnotateMap As IAnnotateMap
Set pMxDoc = ThisDocument
Set pMaps = pMxDoc.Maps
'loop through all the maps
For index = 0 To pMaps.Count - 1
Set pAnnotateMap = New esriMaplex.MaplexAnnotateMap 'cocreate a new MaplexAnnotateMap object
Set pMap = pMaps.Item(index) 'get the map at the current index
Set pMap.AnnotationEngine = pAnnotateMap 'set the map AnnotationEngine to be MaplexAnnotateMap
'after setting the AnnotationEngine, the Map automatically translates all labeling properties to Maplex.
Next index
End Sub