English

How To: Lock features in a layout view

Summary

Instructions provided describe how to lock features in a layout view. The code provided locks features in a layout view.

Procedure

Follow the steps below.

  1. Start ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument then right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    Note:
    Code in the Project's 'ThisDocument' code module only runs in the current map document. To store the code in all the map documents; open the Normal.mxt ThisDocument code module instead.

  4. Copy the following code into the code module.

    Code:
    Sub LockElements()
    Dim pDoc As IMxDocument
    Dim pPageLayout As IPageLayout
    Dim pContainer As IGraphicsContainer
    Dim pElement As IElement
    Set pDoc = ThisDocument
    Set pPageLayout = pDoc.PageLayout
    Set pContainer = pPageLayout
    pContainer.Reset
    Set pElement = pContainer.Next
    While Not pElement Is Nothing
    pElement.Locked = True
    Set pElement = pContainer.Next
    Wend
    End Sub

  5. Close the Visual Basic Editor.
  6. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.