This content has been marked as final. Show 3 replies
Yes, programatically. Create a custom UI button and paste the below code into it.
Create your labels as complex or as simple as you need it then save the layer as a "Layer File"
In the TOC select the layer you want to import the saved labels into then click the button you just created. This opens up a dialog box. Navigate to the saved layer file and hit the Apply Labels button. I put a msgbox at the end because some labels were so complex and scale so large it would sometimes crash arcmap. This way it will give you the opportunity to save the document then adjust the scale. Then just right-click on the layer and "Label Features"
If you want the labels display right away, remove the message box and un-comment the the lines near the end.
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"
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
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
MsgBox "Labels imported successfully." & Chr(13) & "To view labels, check 'Label Features'."
I've tried downloading and installing your tool, but it doesnt seem to want to work. The option to copy over symbology is greyed out
I'm using an Arcview licence if it affects this.
Cheers, hope this works!
Just to let you know, it does indeed work. Apologies!