Claude Martineau

How to execute VBA code on a Context Change

Discussion created by Claude Martineau on Dec 3, 2008
Latest reply on Jan 11, 2011 by spilon

In a ProcessBook context relative display, changing context is not an event on which VBA code can be executed.

 

One way to go around this is to Hide the Module Context pane and to add a Microsoft Forms List Box on the display.  This List Box should be loaded when the display opens with all the modules that are part of the display.  When a module is selected in the Listbox, VBA code is used to set the current display context to this module.

 

The benefits of using this mechanisn are:

  • VBA code can be launched when a new module is selected (a ListBox_Change event is avaialble)
  • The list of available module can be located where best suited on the display.  it does not have to be on the left hand side or to take the whole height.
  • The list of available module does not have to include the hierarchy (which is shown in the Module Context pane) when modules from different locations are used.
  • Adding and removing modules to the display is done the same way as usual, therefore display maintenance issues are minimised.  The modules that are part of the list box are not hard coded.

Outcomes