Throughout this document, it may be helpful to refer to an actual image of WPI's main screen, which is provided below. Note that this is a clickable image. Simply click on any area of the user interface for which immediate help is desired. Otherwise, continue reading the manual.
In either case, WPI sends commands to Word which:
For the sake of completeness, WPI also provides the following clipboard operations that move or copy data from the Selections list to the clipboard:
Note 1: The initial browse folder (directory) is a configurable parameter, which may be modified by changing the contents of the Working Directory text entry field in WPI's configuration screen. The common open dialog box's primary file filter is also configurable and may be modified by changing the contents of the configuration screen's File Types text entry field.
Note 2: Multiple file selections are sorted in accordance with the setting of the "File Sorting" feature.
Note 3: WPI remembers the last 10 folders visited via the Browse button. These 10 folders may be accessed from the File | Recent Folders menu selection and purged via File | Purge Recent Folders.
So why browse the Windows Favorites folder? As it turns out, Windows Explorer supports a little known feature that facilitates the creation of folder shortcuts within the Favorites folder. Example usage:
Note 1: WPI remembers the last 10 folders visited via the Favorites button. These 10 folders may be accessed from the File | Recent Folders menu selection and purged via File | Purge Recent Folders.
When the Selections list has keyboard focus, selected filenames may be deleted from the list (but not from disk) by pressing the Delete or Backspace keys. This list control supports these filename selection techniques:
Finally, all filenames may be delected from the list (but not from disk) by clicking the Clear Selections button.
The net effect of these three commands is that WPI creates a new table in section "a". Additionally, if the settings of the Document Style radio buttons differ from Word's current page orientation (e.g., WPI configured for Landscape and Word configured for Portrait), then the Document Style utilized by WPI will only affect section "a". If a new section is not created and the WPI and Word orientations differ, then WPI's Document Style will modify the orientation of the entire Word document (e.g., all document pages toggled to landscape).
Hints:
NB: The values of these configuration parameters are ignored if:
Conversely, if widths and heights are specified as Exact, WPI computes table cell dimensions appropriate for the currently specified table geometry. WPI's computed dimensions may be adjusted to taste by modifying the values in the Width/Height text entry boxes. Note that in Exact Column Width or Exact Row Height mode, Word scales inserted pictures to fit the dimensions specified in the Width/Height text boxes.
Special Note
All fractional numeric values (e.g., a Row Height of 3-1/2 inches/row) must be specified using a decimal point character appropriate for the host operating system's current locale. For example, the English decimal point is the period ("."), while Germany uses a comma (","). All example fractional numeric values displayed in this document assume the English locale.
In most cases, one space is inserted between the prefix and suffix, but see the list of caption features for an important exception. Two spaces are inserted between the leaf filename and any preceding text.
Notes
Caption Prefix: "Figure" Numeric Suffix: "1" Geometry 2x2 Generated Captions for a 2x2 table: Figure 1 Figure 2 Figure 3 Figure 4
Caption Prefix: "Figure 1-" Numeric Suffix: "1" Geometry 2x2 Generated Captions for a 2x2 table: Figure 1-1 Figure 1-2 Figure 1-3 Figure 1-4
The latter two delimiters must be explicitly enabled via the Underscore and MixedCase checkboxes. Assuming these checkboxes are checked, WPI transforms each of the above leaf filenames into the caption string "Avg Growth Chart".
Creating Descriptive Object-Specific Captions
Caption Prefix: "Figure 2-" Numeric Suffix: "1" Geometry 3x1 Filename Captioning enabled Selections List: c:\temp\Etch Rate Aug 9.jpeg c:\temp\Etch Rate Aug 10.jpeg c:\temp\Etch Rate Aug 11.jpeg Generated Captions for a 3x1 table: Figure 2-1 Etch Rate Aug 9 Figure 2-2 Etch Rate Aug 10 Figure 2-3 Etch Rate Aug 11
Keep this capability in mind when naming graphics/picture files.
This feature works best when Word's cursor is positioned within an empty table cell :-) .
Note 1: A comment is delimited by '#', which must be the first non-whitespace character of a logical script line. Inline comments (i.e., comments that immediately follow a command) are not supported.
Note 2: A plain text file is usually created with a ".txt" suffix (e.g., myscript.txt). In general, word processors do not create text files unless specifically so directed via an appropriate "Save As" option. If in doubt, use Notepad or a text editor to create WPI scripts.
Note 3: Fractional numeric values must be specified using a decimal point character appropriate for the host operating system's current locale. For example, the English decimal point is the period ("."), while Germany uses a comma (","). All example fractional numeric values shown in this document assume the English locale.
Notation | Explanation |
---|---|
{a | b} | Choose "a" or "b". |
<value> | User-specified value. The semantics of value are described in the discussion of the affected script command. |
Notation | Explanation |
---|---|
(I) | Immediate command. |
(W) | This command requires a running instance of Word.
If Word is not running, an error is reported and the script is
aborted.
Note: WPI has no control over which instance of Word receives a particular formatting/configuration command. Therefore, avoid running a script in the presence of multiple instances of Word. Use the kill, open, and/or start commands to establish proper initial state. |
Command | Semantics |
---|---|
break page | inserts a page break in Word's active document (I) (W). |
caption alignment {left | right | center} | set one of the caption Alignment radio buttons. |
caption append filename {on | off} | checks or clears the Append Filename To Caption checkbox. |
caption {on | off} | checks or clears the Add Caption checkbox. |
caption placement {follow | precede | top | bottom} | set one of the caption Placement radio buttons. Note that "precede" and "top" are synonyms, as are "follow" and "bottom". |
caption prefix <string> | specify a Caption Prefix. The string value may be optionally delimited with double or single quotes, which are stripped from the token before use. Delimiters are useful if the prefix's leading/trailing white space must be preserved. |
caption split {underscore | mixedcase} {on | off} | checks or clears a Filename Split At checkbox. |
caption suffix {<integer> | ""} | specify a Numeric Suffix, which must be either an integer value or "". The latter token (an empty quoted string) clears the numeric suffix. |
clear | clear the Selections list box. |
colwidth {automatic | auto | <width>} | set table Column Width
as either "automatic" or an exact numeric value, scaled in
user-configurable units.
Note that "auto" is a synonym for automatic. Example:
# assuming units set to "inches", this # command creates 2-inch wide table column colwidth 2 |
docstyle {unchanged | portrait | landscape} | set one of the Document Style radio buttons. |
exit | terminate WPI |
geometry <rows>x<cols> | specify number of rows and columns in a
newly created table. Example:
geometry 2x4 |
goto {bof | eof} | move the cursor to BOF (beginning of file) or EOF (end of file) in Word's active document (I) (W). |
grid {on | off} | checks or clears the Add Table Grid Lines checkbox. |
halt | stop the current script, but don't terminate WPI. Useful debug aid. |
kill word {save | discard} | close all instances of Word
(I). The save|discard
command arguments dictate whether unsaved changes are saved or discarded.
This command is useful when placed at the beginning
of a script, as it forces WPI to create a new instance of Word prior
to inserting graphics (i.e., the script works from a "clean slate").
It's not an error to issue this command when no instances of Word exist.
When choosing between save|discard, keep in mind these pitfalls:
|
landscape {top | bottom | left | right} <margin> | set landscape margins, scaled in user-configurable units. |
line down | move the cursor down one line in Word's active document (I) (W). |
open {doc | document} <docpath> | open the specified document in a currently running instance of Word (I). If Word is not running, it will be started first. Note that doc and document are equivalent. |
new section {on | off} | checks or clears Create New Section checkbox. |
paper {width | height} <dimension> | set paper dimensions, scaled in user-configurable units. |
portrait {top | bottom | left | right} <margin> | set portrait margins, scaled in user-configurable units. |
postinsert down {1 | 2} | sets either the Line Down or Two Lines Down radio buttons. |
postinsert same table | sets Remain In Table radio button. |
quit | same as exit |
rowheight {automatic | auto | <height>} |
set table Row Height as either
"automatic" or an exact numeric value, scaled in
user-configurable units.
Note that "auto" is a synonym for automatic. Example:
# assuming units set to "inches", this # command creates 3.3-inch tall table row rowheight 3.3 |
save as {doc | html | rtf} <docpath> | save Word's active document in the specified format
to the specified document path
(I) (W). html format is not
supported
in conjunction with use of Word 97 and will result in a runtime
error. Example syntax that saves the active document in "normal" Word
document format to c:\temp\MyDoc.doc:
save as doc c:\temp\MyDoc.doc |
save {doc | document} | save Word's active document
(I) (W).
Note that doc and document are equivalent.
Caution: Word will pop up a "Save As" dialog box if the active document has never before been saved. Until this dialog box is dismissed, the running script will hang. |
selection <filepath> | add the string denoted by filepath to the Selections list box. |
send | send file selections to Word (I). |
sleep <msec> | sleep for up to 30000 milliseconds. Possibly useful debug aid. |
start word | start an instance of Word (I). This command is supplied only for the sake of completeness, since WPI starts Word, if required, prior to inserting graphics/pictures. |
units {cm | mm | inches} | specify the units of WPI's physical document parameters (e.g., paper width, landscape margins, exact colwidth, etc.). |
# Place 4 graphic files in a Word table and then terminate WPI. # Captions and all other WPI parameters default to current WPI settings. selection c:\temp\wpipics\analysis01.png selection c:\temp\wpipics\analysis02.png selection c:\temp\wpipics\piechart.bmp selection c:\temp\wpipics\wrapup.jpg send exit
# Place and caption 4 graphic files in a Word table and then terminate WPI. # Caption will be Figure 1-1, Figure 1-2, etc. caption on caption prefix Figure 1- caption suffix 1 selection c:\temp\wpipics\analysis01.png selection c:\temp\wpipics\analysis02.png selection c:\temp\wpipics\piechart.bmp selection c:\temp\wpipics\wrapup.jpg send exit
# Place and caption 4 graphic files in a Word table and then terminate WPI. # Captions modified on the fly to match graphic file contents. caption on # create captions "Analysis 1", "Analysis 2", etc. caption prefix Analysis caption suffix 1 # don't move cursor out of table following insertion postinsert same table selection c:\temp\wpipics\analysis01.png selection c:\temp\wpipics\analysis02.png send clear # create caption "Distribution Pie Chart" caption prefix Distribution Pie Chart caption suffix "" selection c:\temp\wpipics\piechart.bmp send clear # create caption "Wrapup Summary" caption prefix Wrapup Summary selection c:\temp\wpipics\wrapup.jpg # after final graphic inserted, step cursor out of table and down 2 lines postinsert down 2 send exit
WPI command line syntax is as follows:
[-s <scriptfile>] [-v]
where:
-s <scriptfile> specifies the path to a file containing WPI scripting commands -v indicates that before a script is executed, WPI should become visible (i.e., draw its main window) and insert small delays between each script command. This switch permits the user to monitor the script's actions in (somewhat) real time. If -v is omitted, WPI remains invisible the entire time the script executes. This command line argument is further discussed in Scripting Hints.
Do this Not this geometry 1x3 colwidth 2.25 colwidth 2.25 rowheight 3 rowheight 3 geometry 1x3
#colwidth & rowheight were just clobbered
break goto kill line open save send start
Buffered Word commands are remembered and executed when a send command is encountered within a script.
An example illustrates how buffered commands might lead to surprises. Note below the two different scripts used to move the cursor down two lines following graphics/picture insertion--one works, the other does not.
Do This Not This selection pic1 selection pic1 selection pic2 selection pic2 postinsert down 2 send send postinsert down 2 <-- never sent to Word exit exit <-- because WPI exits here
On the other hand, to immediately move the cursor down two lines in a running instance of Word, use these commands:
line down line down