Programatically Turning on the Survey Analyst Extension

Created:12/20/2002
Description:

This sample programatically turns on the Survey Analyst extension. The code below can be added to the GxDocument_OpenDocument subroutine and/or the MxDocument_OpenDocument function, to ensure that the extension is automatically turned on if the Survey Analyst extension is installed.

How to use:
  1. Open VBA (Alt+F11 shortcut) in ArcMap.
  2. Paste the code from the MxDocument_OpenDocument function below.
  3. Save the map document if you are not in the VBA Normal project.
  4. Open VBA (Alt+F11 shortcut) in ArcCatalog.
  5. Paste the code from the GxDocument_OpenDocument subroutine below.
Private Function MxDocument_OpenDocument() As Boolean
  Dim pUID As IUID
  Set pUID = New UID
  pUID.Value = "{B679B84A-13FC-11D6-9269-00508B48AE82}"
  Dim pExt As IExtension
  Dim pExtConf As IExtensionConfig
  Set pExtConf = Application.FindExtensionByCLSID(pUID)
  If Not pExtConf Is Nothing And pExtConf.State = esriESDisabled Then
    MsgBox "Turning on the Survey Analyst Extension."
    pExtConf.State = esriESEnabled
  End If
End Function

__________________________________________________________________________________________

Private Sub GxDocument_OpenDocument()
  Dim pUID As IUID
  Set pUID = New UID
  pUID.Value = "{B679B84E-13FC-11D6-9269-00508B48AE82}"
  Dim pExt As IExtension
  Dim pExtConf As IExtensionConfig
  Set pExtConf = Application.FindExtensionByCLSID(pUID)
  If Not pExtConf Is Nothing And pExtConf.State = esriESDisabled Then
    MsgBox "Turning on the Survey Analyst Extension."
    pExtConf.State = esriESEnabled
  End If
End Sub