Complete the following steps to add a custom step type to the Surround Selection With context menu of the Steps pane and to add an end step after the last step in the contiguous block of steps you selected.

  1. Complete the following steps to add the custom step type to the Surround Selection With context menu.
    1. Right-click the custom step type and select Properties to launch the Step Type Properties dialog box.
    2. Click the Advanced button and select Block Structure from the drop-down menu to launch the Block Structure dialog box.
    3. Enable the Can Surround a Selection of Steps option to include the custom step type in the Surround Selection With context menu.
  2. Create an OnNewStep substep to execute when you insert an instance of the custom step type.
  3. Create a code module for the OnNewStep substep to check the value of the Boolean SequenceContext.RunState.ShouldEncapsulate property to determine where to add a corresponding end step.When you use the Insert Step menu or the Insertion Palette to insert a new step, the SequenceContext.RunState.ShouldEncapsulate property does not exist, and the SequenceContext.SelectedSteps property contains the newly inserted step.When you use the Surround Selection With menu to surround a set of selected steps with corresponding begin and end steps, the SequenceContext.RunState.ShouldEncapsulate property is True, and the SequenceContext.SelectedSteps property contains the set of selected steps.In the code module for the OnNewStep substep, verify that the SequenceContext.RunState.ShouldEncapsulate Boolean property exists and is True. When the SequenceContext.RunState.ShouldEncapsulate property is True, you must add the corresponding end step after the last step of the selected steps. When the SequenceContext.RunState.ShouldEncapsulate property is False or does not exist, you can add the end step after the newly inserted step or in another location you specify.