VBA: Turn Off Extensions

Written by Bert Granberg,


This script was written to turn off all ArcMap extensions previously in use when a new map document is opened. Install it in your Normal.mxt This Document code window and save. Should work in 9.1 and 9.2. Private Function MxDocument_OpenDocument() As Boolean
   
    Dim i
    Dim pUID As UID
    Dim pIJITExtMgr As IJITExtensionManager
    Dim pExtMgr As IExtensionManager
    Dim pExtConf As IExtensionConfig
    Dim pExt As IExtension
    Set pIJITExtMgr = Application
    Set pExtMgr = Application
   
    For i = 0 To pIJITExtMgr.JITExtensionCount - 1
       
        Set pUID = pIJITExtMgr.JITExtensionCLSID(i)
        Set pExt = pExtMgr.FindExtension(pUID)
       
        If Not pExt Is Nothing Then
           
            'Debug.Print pExt.Name
       
            If TypeOf pExt Is IExtensionConfig Then
               
                Set pExtConf = pExt
               
                If pExtConf.State = esriESEnabled Then
                   
                    pExtConf.State = esriESDisabled
               
                End If
           
            End If
        End If
    Next
   
    For i = 0 To pExtMgr.ExtensionCount - 1
       
        Set pExt = pExtMgr.Extension(i)
       
        'Debug.Print pExt.Name
       
        If Not pExt Is Nothing Then
            If TypeOf pExt Is IExtensionConfig Then
               
                Set pExtConf = pExt 'QI
               
                If pExtConf.State = esriESEnabled Then
               
                    pExtConf.State = esriESDisabled
                   
               
                End If
           
            End If
       
        End If
   
    Next
   
End Functio

Users' Comments  
 

No comment posted

Add your comment

02, Jun. 2008