Working with Views

Created:04/13/2001
Description:

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.
Public Sub OpenView()
  Dim pApp As IGxApplication
  'Get a refence to the application
  Set pApp = Application
  'Create a UID Object to hold the ClassID of the view
  Dim aUID As New UID
  
  'aUID = "esricore.gxcontentsview"        'used to open contents view
  aUID = "esricore.gxpreview"              'used to open preview view
  'aUID = "esricore.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 = "esriCore.GxGeoGraphicView"
    'aUID.Value = "esriCore.GxTableView"    'for the table view
    ppreview.ViewClassID = aUID
  End If
End Sub