How to lock customization in the normal template


The Lock Customization button on the Customize dialog locks the customization functionality so that you can't make changes to the user interface or write VBA code. If you Lock Customization in ArcMap, that state only gets stored in the current document. In ArcCatalog, the lock only is active in the current session. The lock state doesn't get saved in the Normal template; it doesn't get restored when you restart the application. However, you can programmatically set a lock that gets activated every time the applications are started.

How to use

  1. Paste this code in the Normal.ThisDocument code window in the Visual Basic Editor.
  2. When you restart the application, the lock will be activated.
  3. To unlock the application, click the Tools menu and click Customize and then type in the password "myPassword".
  4. To prevent locking again, be sure to delete this code from Normal.ThisDocument.
[VBA]
' The following VBA code for the ArcMap Normal template applies a customization
' lock whenever a document is opened or a new docuement gets created.

Private Function MxDocument_NewDocument() As Boolean
    Application.LockCustomization "myPassword"
End Function

Private Function MxDocument_OpenDocument() As Boolean
    Application.LockCustomization "myPassword"
End Function


' The following VBA code for the ArcCatalog Normal template applies
' a customization lock whenever the application is started.

Private Sub GxDocument_OpenDocument()
    Application.LockCustomization "myPassword"
End Sub