Word Automation - Creating Custom Forms and Printouts

 

Many law enforcement agencies have special or custom forms that they need to complete for one reason or another. Since there are so many different forms in use throughout the states and counties, it is impossible for Crimestar to even begin to replicate all of them. For this reason Crimestar RMS contains a powerful feature referred to as "Word Automation" that allows you to create template files in Microsoft Word (version 9 or above) that contain bookmarks. By using certain pre-defined keyword for your bookmark names, Crimestar will replace your bookmarks, in your document, with data from a specific database record. The result is that with the click of a button, you can get YOUR form, designed the way you design it, with Crimestar data automatically inserted. Since you can create an unlimited number of Word template files, the number of custom/special forms and printouts you can create in unlimited.

 

When you click the Word Automation command button you will be prompted to select the Microsoft Word Template (.dot) file that you wish to use. Select the appropriate (.dot) file and Crimestar will use MS Word to print your template replacing that templates defined Bookmarks with the data from the selected Crimestar data record.

 

How to Create a Microsoft Word Template file

 

To create a Microsoft Word Template file, run Microsoft Word and layout your document as desired. Then from the FILE menu of Word, select "Save As". When the Save As file dialog box appears, name your document and change the File type setting from Document (.doc) to Template (.dot). Be sure to note the specific directory where you are saving your template, so you can find it again later.

 

Creating Bookmarks within your Word Template

 

Creating a Bookmark within your MS Word template file is simple. First layout your document and include a text marker where you want a specific data element to be placed. Then select the text of that marker and create a Bookmark reference to it. By naming the Bookmark reference with a specific keyword name Crimestar will instruct MS Word to replace the textual marker with the data from the Crimestar data record. Suppose we created a template file and in that file we included the following sentence:

 

The subjects last name is LastNameMarker

 

Note, that the use of LastNameMarker has no specific meaning per-se. We could have just as easily used the letter X. It is merely a placeholder that we will associate with a bookmark. Now we select the text marker that we created as follows:

 

The subjects last name is LastNameMarker

Now with the text marker selected, from the MS Word main menu select Insert then select Bookmark. You will then be prompted to give the bookmark a name. Here is where the name you choose DOES matter! By using a specific KEYWORD name defined below, Crimestar will pass certain information to MS Word, and instruct Word to replace your text marker with the text or information passed to Word by Crimestar. So in our example above, if we were creating a template to be used with the Citation module and we wanted the text marker of LastNameMarker to be replaced with the Last Name of the violator from a Citation record, we would name the Bookmark "v_citation_last_name". This is a special Keyword name that Crimestar searches for and replaces with specific predefined information. We discuss these keywords in more detail below. So if we recalled a citation record where the subjects last name is smith, then selected our template file for printing MS Word would print:

 

The subjects last name is Smith

 

Note that Crimestar specifically looks for the use of certain keywords as Bookmark names and replaces the text defined by that bookmark with the text from the Crimestar data record. As such the length of the text marker does not really matter. As noted earlier in our example above the text marker could have been a single letter such as "x" and the substitution of "x" with the last name "Smith" would have worked the same way.

 

Understanding the Bookmark Keyword names that must be used

 

Bookmark keywords are the special Microsoft Word Bookmark names that Crimestar RMS searches for in order to replace the bookmark text with data from the Crimestar data record. The bookmark keywords are assembled using a specific syntax as follows:

 

Syntax: ROOTKEYWORD [ instance][_description][_dupNN]

 

ROOTKEYWORD: This is a keyword name that is created by joining the name of the database view (table) with the actual field name.

 

Example: If in the warrant module, the keyword that represents the subjects last name would be "v_warrant_recall_last_name" since the modules view (table) name is "v_warrant_recall" and the field name is "last_name". Note that an underscore character is ALWAYS used to join the view and field name. You can obtain a list of the available rootkeywords for a specific module by right-clicking on the word automation command button located in the upper right corner of a module form. Once you have the list of root keywords you can extend the usage of that list with the following rootkeyword phrase extensions.

 

INSTANCE: This phrase is a number that is appended immediately to the rootkeyword to represent the instance of the reference. When referencing modules such as Citations where there is only one citation record, but there may be several offense records, we need a way to reference offense #1, offense # 2, offense # 3 etc. Since the field name will be the same for each record we must differentiate between records so we can create a unique keyword to use as a bookmarks.

 

Examples:

 

The keyword for the first violation would be the rootkeyword: "v_citviolation_violation"

The keyword for the second violation would be: "v_citviolation_violation2"

The keyword for the third violation would be: "v_citviolation_violation3"

The keyword for the fourth violation would be: "v_citviolation_violation4"

 

_D: Since some data fields stored in the Crimestar database tables are merely code references to user defined code tables, it is often desirable to print the description of the code rather than the code itself. In such circumstances appending the phrase " _d" will cause Crimestar to replace the bookmark keyword with the literal description of the code.

 

Examples: In the above description of how and when to append an INSTANCE reference the example shows how to list the violation code for 4 different violations associated with a citation. However to show the description of the violation instead of the violation code the keywords would be as follows:

 

The keyword for first violation description would be: "v_citviolation_violation_d"

The second violation description would be: "v_citviolation_violation2_d"

The third violation description would be: "v_citviolation_violation3_d"

The fourth violation description would be: "v_citviolation_violation4_d"

 

_DUPNN: One of the limitations of using Microsoft Word Bookmarks is that you can only defined a bookmark name reference once. As such if you need to place the same information in multiple places within the same document you can not use the same bookmark reference for all of them. Crimestar handles this by providing the "_dupn" (where n is a number from 02 to 20 ) phrase extension to the keyword. By appending the _dupnn extension you can have multiple unique keyword bookmarks that all reference the same data.

 

Example: Suppose on a warrant you wanted to print the subjects last name 5 times. You would use the following 5 keywords for your bookmarks to all reference the same subject last name:

 

v_warrant_recall_last_name

v_warrant_recall_last_name_dup02

v_warrant_recall_last_name_dup03

v_warrant_recall_last_name_dup04

v_warrant_recall_last_name_dup05

 

Example: suppose in the above example where use of the _d phrase is explained you wanted to show the violation description 2 times. You would reference bookmark keywords as follows:

 

v_citviolation_violation_d

v_citviolation_violation_d_dup02

 

Example: suppose in the above example where use of the _d phrase is explained you wanted to show the third violation description 2 times. You would reference bookmark keywords as follows:

 

v_citviolation_violation3_d

v_citviolation_violation3_d_dup02

 

Extending Word Automation beyond the Crimestar data tables

 

In some circumstances it may be desireable or necessary to prompt the user to enter additional information to be included into your word automation document. Crimestar provides a very simple means to extend word automation using a special text file. The text file holds a series of prompts or questions that are presented to the user immediately before the word automation document is printed or saved to disk. When the user answers these prompts or questions their answers can be included into the word automation document using the same bookmark text replacement concept as is used for database records.

 

To enhance Crimestar word automation using this input extension feature you simply create a text file named "waextra.txt". Each line in the file will contain 3 pieces of information separated by a vertical bar character "|". The information needed is the name of Word Automation Template file name, the Bookmark Keyword used in the template file and the question or prompt that you want the user to see. Each user prompt is placed on a new line in the text file and the prompts will be displayed to the user in the same order that they appear in the file. The waextra.txt word automation extension file can contain prompts for an unlimited number of different word automation templates. Below is the format for a single prompt entry in the file.

 

TEMPLATE_FILE_NAME | BOOKMARK | QUESTION OR PROMPT

 

Example: If we wanted to ask the user 2 additional questions whenever they selected the WARRANTS.DOT template file and we wanted the answers to those questions to be placed into the output document using bookmarks named mydata1 and mydata2, we could add the following two entries to the waextra.txt text file.

 

WARRANTS | mydata1 | Enter the Judges Name

WARRANTS | mydata2 | Enter the Address for the court

 

You can specify the default location where Crimestar will look to find both Word Template files and the waextra.txt extension file by setting the WORD_TEMPLATE_PATH entry of the Crimestar.INI file. This entry should be located in the [CONFIGURATION] section of the Crimestar INI configuration file and if it does not exist you can simply create it.

 

Hiding/Disabling the Word Automation feature

 

The word automation command button is located in the upper right corner (near the help button) on certain Crimestar module forms. By default the word automation command button is enabled. If you do not wish to use the word automation feature and would rather not see or have the command button available for users to click, the command button can be deactivated. To disable the command button, add or change any of the following entries in the [CONFIGURATION] section of the Crimestar INI file on the local workstation.

 

WORD_ACCIDENT=OFF

WORD_ANIMAL=OFF

WORD_BICYCLE=OFF

WORD_BOL=OFF

WORD_BOOKING=OFF

WORD_CIVIL=OFF

WORD_CITATION=OFF

WORD_COMPOL=OFF

WORD_CFS=OFF

WORD_FI=OFF

WORD_FIREARM=OFF

WORD_INCIDENT=OFF

WORD_MNI=OFF

WORD_PAWN=OFF

WORD_PROPERTY=OFF

WORD_REGISTRANT=OFF

WORD_WARRANT=OFF