Wanting a UIControl Button to apply .lyr file symbology and labels to a map layer(VB)

Discussion created by MattSmith42 on Apr 22, 2010
I need to create a button that will apply the symbology and label from a previously saved .lyr file to a feature class or shapefile in ArcMap.

Does anyone have any Visual basic script that will do this.

I've found some script on the arcscripts site that take the label settings from a .lyr file and apply it to the selected layer:

    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 "Please 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"
    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.CurrentContentsView.Refresh pGFLayer

This code works fine, but would it be a relatively simple task of adapting this code to have it apply the symbology also? I'm very much a newcomer to writing code.