ArcGIS Desktop – Saving Custom Labeling Templates for Other Feature Classes

arcgis-10.0arcgis-desktoplabeling

I sometimes work with large NTDB datasets, and was just wondering the best way to go about saving all of my custom labelling.

Is there a way I can save all of my custom label classes so I can apply them to all of my NTDB datasets so all maps made with this dataset are standardized?

I can do it the long way by changing the classes every time, but just wanted to know if I could save it so I can just apply it i.e. like a layer file?

Best Answer

You could just save the layer file then create a UI button (or an Add-on in v.10) and use the following code to import the labels:

    Dim pGxFile As IGxFile
    Dim pGFLayer As IGeoFeatureLayer
    Dim pGxLayer As IGxLayer
    Dim pGxDialog As IGxDialog
    Dim pGxObjFilter As IGxObjectFilter
    Dim pEnumGxObj As IEnumGxObject
    Dim pAnnoLayerPropsColl As IAnnotateLayerPropertiesCollection
    Dim pGxObj As IGxObject
    Dim pMxDoc As IMxDocument

    Set pMxDoc = ThisDocument
    If pMxDoc.SelectedLayer Is Nothing Then
        MsgBox "Select feature class to label with .lyr file label classes"
        Exit Sub
    End If

    Set pGxDialog = New GxDialog
    Set pGxObjFilter = New GxFilterLayers
    Set pGxDialog.ObjectFilter = pGxObjFilter
    pGxDialog.Title = "Select Layer(.lyr) file to import labels definitions from"
    pGxDialog.ButtonCaption = "Apply Labels"

    If pGxDialog.DoModalOpen(0, pEnumGxObj) Then
        Set pGxObj = pEnumGxObj.Next
        Set pGxLayer = pGxObj
    Else
        Exit Sub
    End If

    Set pGFLayer = pGxLayer.Layer
    Set pAnnoLayerPropsColl = pGFLayer.AnnotationProperties

   'Apply label classes  to selected layer in arcmap

    Set pGFLayer = pMxDoc.SelectedLayer
    pGFLayer.AnnotationProperties = pAnnoLayerPropsColl
'    pGFLayer.DisplayAnnotation = True
'    pMxDoc.ActiveView.Refresh
    pMxDoc.CurrentContentsView.Refresh pGFLayer

    MsgBox "Labels imported successfully." & Chr(13) & "To view labels, check 'Label Features'."