Technical Issues - Report Generator Tutorial III - MS Word
The Report Generator produces
high quality documents, but
some requirements exceed its capabilities. We considered this issue upon
receiving a contract with one column in Russian and the other in English. In
such cases it is preferable to create documents in Microsoft Word. From
the point of view of the end-user, say a QA lab technician, the process is
seamless since Word is under control of FilmStar BASIC and the user need not
know that Word is being utilized.
1. Create Word document: After creating the document, field codes (search Word help) are utilized to insert text. The most important field code for our purpose is DOCVARIABLE. By setting .Variables("NAME") = "William F. Cody" in FilmStar BASIC code, Word will replace DOCVARIABLE NAME with "William F. Cody". In the screen shot below we use labels (NAME, PARTID, RANGE1, etc.) that will be part of our field codes.
Once labels are replaced by actual field codes the document resembles the following:
<Alt+F9> toggles all field codes on and off. They gray areas indicate that entries are field codes and do not appear when printed.
3. Bookmark graph location(s): In our example, an FSPlot graph is saved (Sub PlotSave) as temp.wmf. This is then utilized in Word's .InlineShapes.AddPicture command. A bookmark sets the range where the picture will be rendered. Referring to the screen shot at the top of this page, we place bookmark Graph at the position denoted by Graph goes here. This is accomplished with Insert.. Bookmark.
Where's the bookmark? According to Microsoft, "1.Click the Word File tab and then click Options. 2.Click Advanced, and then select the Show bookmarks check box under Show document content. 3.Click OK." As indicated below it appears as an I-beam.
Some comments on FilmStar BASIC code MeasureQA_Word.bas.
Here we activate FSPlot, plot the data and save it. Note the Wait statement. Without such delays hang-ups are inevitable. We think this point is sometimes missed and suggest it is the reason instruments such as Cary 2300-2400 series and PE Lambda 4/6 only work with very old slow computers.
Once a reference is established to MS Word (dWord.ActiveDocument), we are really running Word VBA from FilmStar BASIC. That's where Word commands are documented, not in FilmStar help. But you do not have to leave FilmStar BASIC to get the syntax and paste commands. Click Debug.. Browse or the Browse Object icon to bring up the following dialog: