WORD
FORMS
Anil Mitra, Copyright © 2002
§ Documents laid out using frames, tables… as a form with “form protected” parts that cannot be changed and “formfields” where the user enters information. In the following formfield may be abbreviated as field
§
If divided into sections, each section can be
individually protected
§
Are constructed in unprotected mode, then protected. When protected, a password can be entered
that is needed to unprotect and change the design
§
Basic types are dropdown list, textentry field and checkbox – all are part
of the Word Object model. There are other ActiveX types that are functionally
more flexible but not part of the object model less easy to design for
§
Have a number of properties. The most important
are .Name [a bookmark], whether .Enabled [true/false], .Result
– what is displayed which has a default value [at load], and exit and
entry macros. When the document is form protected the user can change
only the .Result of .Enabled = true fields
§
Name identifies the field; .Result is what is
displayed and has a default value that shows when the form is loaded or
unprotected, and user entered data is changes the value of the .Result. The
.Result can be changed by the user only when .Enabled = True
§
Macros [VBA, not restricted to entry/exit] – can
change about anything: protection, the fields themselves, .Result – even when …
.Enabled = False
§
A line is a set of form fields on a Word line
§ A group is a set of consecutive lines [or fields or groups] that [usually] has similar structure, e.g. the same sequence of field types; there may be additional similarities. These groupings are convenient since they occur in practice and it is convenient to have standard routines for manipulation of the groups. In the case of similarity in structure the code is simpler. In the following, “element” will refer to a group, line or field
§ Recognizing selection point location – the containing element. This can be done by having separate on entry macros for each element that say Public Variable = element number. To recognize which field the user entered, each element would have its own macro that that set Public Variable = .Name. Recognition would be simpler through Selection.Formfields[1].Name but for an apparent bug in the MS Word FormFields Object Model which does not recognize a textentry field as a selected object
§ Add/delete an element on command. This can be done before the user has begun to enter data or after. If after, the element should be in a section that will not yet have data entered. The macro first unprotects the section, writes the element and then reprotects. This makes the form dynamic and this is an advantage over the apparent write/delete of the next item but automation is harder to program. When reprotecting every element in the section is reset to the default and this can be avoided by having custom elements in their own sections
§
Rewrite element.Result
and set .Enabled = True/False. Thus elements can be “deleted” – the macro sets
.Result = “ “ [the space is necessary] and .Enabled =
False. During entry the elent is passed over and
cannot be selected. Thus elements can be deleted and written [if deleted by
default or initialization – either by macro or template] or rewritten
§
Move up / down, add, delete,
automate result – all combinations of rewrite
§ Engineer a field as an element – the engineering issue is that an “invisible” dropdown and a textentry field may be combined as a element and the dropdown used to locate the selection point, e.g. by having the entry/exit macro to the textfield refer/go to the dropdown field… will investigate this idea as it would overcome the bug noted above. Note that there is no loss in generality by considering elements – since a field can be considered to be a element of one item
ANIL MITRA
| RESUME | HORIZONS ENTERPRISES™ | HOME | SITE-MAP | USEFUL
LINKS | CONTACT
PHILOSOPHY OF MIND