3 Replies Latest reply on Sep 3, 2012 12:12 PM by 8556732

    Is there a way of Importing Label Styles as you do Symbology?

      Is there a way to do this. I'm in a situation where I have about 100+ shapefiles I need to style with the same type of labels. It is a tedious process where I have to create two label classes for each shapefile to place a label on the top and the bottom of a point. Is there a quick way to do this? Such as the way you import the symbology from another layer file?
        • Re: Is there a way of Importing Label Styles as you do Symbology?
          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"
                  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
                  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'."
          • Re: Is there a way of Importing Label Styles as you do Symbology?

            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!