Using Visio as a Forms Tool: Automated Forms Example
Microsoft Visio 2000
Summary: This article demonstrates how a Visio drawing can be automated to act like a forms package. (3 printed pages)
The Automated Form demonstration shows how a Microsoft® Visio® drawing can be automated to act like a forms package. This demo allows the user to build forms using custom forms shapes. When the user goes to fill out the form, they can use the TAB key to enter the text of the next form field.
This demonstration also includes two utilities for making a form editable (Creation mode) and lock down a form (User Fill-In mode). This demonstration can be extended to include new form shapes that automatically participate in the tabbing order; it can also be extended to include tie-ins to databases.
- Easy-to-use forms package makes it simple to create forms and fill them out.
- Automated Forms can be the starting point for more sophisticated, database-integrated forms.
How to Set Up
- Drop the templates into the Visio \Solutions directory; you can put the templates under their own directory or under an existing one. The templates and stencil then show up under the Visio New menu and Stencil menu.
- Since VBA code provides the tabbing behavior, you must start a new form with one of the templates. The shapes will not exhibit the tabbing behavior unless used with these templates.
To create a new form
- There are two templates provided. The first, Automated Form.vst, is used to create a new form. Start with this template.
- Drag and drop components from the Automated Form stencil onto the page. Keep track of the z-order (stacking order) of the shapes. The stacking order will determine the tabbing order. Use the Send Forward and Send Backward commands to change the stacking order of shapes.
- When done constructing the form: On the Tools menu, click Macros, click ThisDocument, and then click Lock Form. This will prevent further changes and movement of the boxes.
- On the File menu, click Save As, and then save the completed form as a Template (.vst) file. Your users can then select this template when they need to fill out a new copy of your finished form.
To fill in a form
- Choose a preconstructed form template. (For example, Form.vst is a completed form.)
- Highlight the first box by selecting on it.
- Type in the value.
- Tab to go to the next field.
- On the File menu, click Save.
To create a new forms shape
- Create a shape as you normally would.
- Open up the ShapeSheet and add a user cell named “User.Field” to the User section.
- Save the shape
This shape will now be a valid shape to tab to automatically.
To modify an existing form
- Open the form template or drawing file.
- On the Files menu, click Macros, click ThisDocument, and then click Edit Form.
- This will make all the shapes on the page editable
- Make the necessary changes.
- On the Files menu, click Macros, click ThisDocument, and then click Lock Form. This will prevent further changes and movement of the boxes.
- Save the new form.
How It Was Designed
This example shows the use of:
- The CallThis function within the ShapeSheet
- ShapeSheet Event section cells
- VBA automation
- Typed shape (a shape design pattern)
Using these capabilities, we are able to respond to keystrokes, check to see if a shape is to be included in the tab rotation, and automatically position the focus to the proper shape.