How to work with views


This tip demonstrates how to change views. All of the possible views are included here, and the code can easily be modified to open any view.

How to use

  1. Paste this macro into VBA.
  2. Edit the code to open the required view.
  3. Run this macro.
[VBA]
Public Sub OpenView()
    
    'Get a refence to the application
    Dim pApp As IGxApplication
    Set pApp = Application
    
    'Create a UID Object to hold the ClassID of the view
    Dim aUID As New UID
    'aUID = "esriCatalogUI.gxcontentsview"        'used to open contents view
    aUID = "esriCatalogUI.gxpreview" 'used to open preview view
    'aUID = "esriCatalogUI.gxdocumentationview"   'used to open metadata view
    
    'open the view
    pApp.ViewClassID = aUID
    
    'To open geographic or table view the preview must be opened
    'then open the type of preview required
    If (TypeOf pApp.View Is IGxPreview) Then
        Dim pview As IGxView
        Dim ppreview As IGxPreview
        Set pview = pApp.View
        Set ppreview = pview
        aUID.Value = "esriCatalogUI.GxGeoGraphicView"
        'aUID.Value = "esriCatalogUI.GxTableView"    'for the table view
        ppreview.ViewClassID = aUID
    End If
    
End Sub