HOW TO
ICustomizationFilter can be used to prevent end users from opening the Visual Basic Editor and viewing or editing the code a document.
Note:
Code in the ThisDocument code module will only run in the current map document. To store the code in all the map documents, open the Normal.mxt ThisDocument code module.
Code:
Private Function MxDocument_OpenDocument() As Boolean
'Do error checking in case there is already a lock active.
On Error GoTo lockErr
'Create an instance of the custom customization filter, MyFilter
Dim m_CustomFilter As ICustomizationFilter
Set m_CustomFilter = New MyFilter
'Lock customization using MyFilter.
'In this example, "MYLOCK" is the password.
Application.LockCustomization "mylock", m_CustomFilter
Exit Function
lockErr:
MsgBox "There is already an active lock.", , "Lock Error"
End Function
Code:
'MyFilter.cls
Option Explicit
Implements ICustomizationFilter
Private Function ICustomizationFilter_OnCustomizationEvent _
(ByVal custEventType As esriCore.esriCustomizationEvent, _
ByVal eventCtx As Variant) As Boolean
If custEventType = esriCEShowCustDlg Then
ICustomizationFilter_OnCustomizationEvent = True
Exit Function
End If
' Lock the Visual Basic editor
' custEventType is esriCEShowVBAIDE
' eventCtx is nothing
If custEventType = esriCEShowVBAIDE Then
ICustomizationFilter_OnCustomizationEvent = True
End If
End Function
Article ID:000004891
Get help from ArcGIS experts
Download the Esri Support App