theThought's thoughts

Kevin A Gray - Creative Strategy Guy

Building the Core Components - Data Collection Populates form using Custom Parts (the Word Doc)

The final component of this process is the Word document itself.  The construction of this document is in two parts:

1.       The layout

2.       The form fields

In previous posts I have created the survey that will capture the customer feedback (the survey) and I have devised the structure of the XML that makes up the custom part (the custom part). In this post I create the final piece of the puzzle before working on the automation of the process.

Step 1: the layout
As the document is basically a form I have used a basic table construct to create the layout, as shown in the following image..

Image001

Step 2: the form fields

The data displayed in the form will be sourced from the custom part.  Word provides a small number of form fields that can be bound to a custom part.  The actual binding cannot be performed within the Word interface but the fields can be inserted ready for binding later.  These fields are available through the Developer ribbon.  This ribbon is not displayed by default,  consequently the first step is to change the default settings of Word so that it is displayed.  To do this perform the following Steps

Ø  Click on the Round Office Logo in the top left corner of Word

Ø  Click on the Word Options button at the bottom of the menu

Ø  Click on the Popular Tab (if it is not already displayed)

Ø  Check the box Show Developer tab in the ribbon

Ø  Click OK

The following image shows the location of this option:

Image002

Once the Developer Tab has been switched on the following ribbon can be displayed by clicking on Developer

Image003

The control section of this ribbon provides access to the form fields.  As this form is for printing and review not for entry only the basic text field is to be used.  This will allow the placement of text fields within the table.

Ø  To insert a text field perform the following steps:

Ø  Click in the document where you would like the field to appear

Ø  Click on the Text Field button

The key option is Design Mode.  When in Design mode it is possible to insert and edit the Form Fields.  The text field will be inserted at the current cursor position.  The text field properties then need to be changed so that it is distinguishable from the other fields that will be placed onto the form.  To edit the field perform the following steps:

Ø  Right Click on the Form Field

Ø  Select Properties

Ø  Enter a Title for the Form

Ø  Click OK

Ø  Select the text inside the field

Ø  Press the delete key to remove it

The following diagram shows the Properties dialog:

Image004

Once all the forms have been created in this way the following form is visible:

Image005

The next stage in the process is to create a static version of the document that contains the values from a custom part.

Filed under  //   Form Fields   Microsoft   OpenXML   PASW Data Collection   custom part   docx  

Three Critical Parts to an OpenXML package

So the first thing to learn is the basic, underlying structure to an openXML document whether it is for Word, Excel or Powerpoint.  Each document is a compressed collection of XML documents wrapped into a single file.  Each of these XML documents is called a “part” while the wrapper is called a package.

When a new package is created it must consist of three core elements:

·         A MainPart – this is the main document being created

·         A CollectionTypes Part – this describes the types of parts that are included in the document (Word, Excel, Powerpoint, image, video etc)

·         A relationships part – this defines the relationships between each part

A package must contain all three, if it does not then it is not considered a valid package, it is effectively just a WinZip file with a funny extension.

The easiest way to see this is to perform the following steps:

1.       Open Word 2007 (or later)

2.       Enter a single line of text

3.       Save the document as a DOCx file

4.       Close the document

5.       Open Winzip

6.       Select Open Archive from the File menu

7.       Point to the DOCx file

8.       Click OK

The following figure shows what the zip file should look like.

Fig_1

As can be seen from this image there are three files in the package.  The first is the relationships file (.rels) this sits is a sub-folder off the root of the document.  The second is the content types document and the last is the main part of the document that contains the content of this document.  Each of them is a well formed XML document.

In version 1.0 of the openXML SDK each of these parts would have to be created manually then placed together into a single compressed file.  In version 2.0 of the openXML SDK there are methods that allow the rapid creation of these three documents by simply creating the main part document.

Filed under  //   ContentTypes   DOCx   Excel   MainPart   OpenXML   OpenXML SDK 2.0   Package   PowerPoint   Relationships   SPSS   WinZip   Word 2007