With End-With Autocompletion

Benefit

All With statements must be followed by an End With statement. After you finish typing the Withstatement , VbaPrime will automatically add the following End With statement.


Demonstration

The following animation demonstrates the End With being automatically added, and the cursor being placed on the line between.


Example

Perform the following steps to see vbaPrime complete a With-End-With combination.

  1. Open the Visual Basic Editor (VBE) and double-click on a module to open up its code window.
  2. Type Sub TestSub() and then press enter. The VBE will automatically add the End Sub statement and place the cursor between them.
  3. Now type With x, then press the enter key.
  4. Observe that VbaPrime automatically enters the End With statement and places the the cursor above it. VbaPrime also indents the code by one tab.

Existing Code

When you press the enter key, VbaPrime will check to see if there is already an End With statement that corresponds to the With statement. If there is an End With, VbaPrime will not add any code. This feature prevents spurious End With statements being added as you navigate around existing code.