HOW TO

Lock features in a layout view

Last Published: April 25, 2020

Summary

Note: 
The information in this article applies to ArcGIS versions 8.x only. Visual Basic for Applications (VBA) for ArcMap and ArcCatalog has been deprecated at ArcGIS 10.

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, 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.
  1. Copy the following code into the code module.
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
  1. Close the Visual Basic Editor.
  2. Run the code.
    1. Click Tools > Macros > Macros to display the Macros dialog box.
    2. Select a macro and click Run.

Article ID:000007254

Software:
  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic