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  

First Tools in the Box

In order to be able to construct my first example I needed some tools.  Although most of the examples provided are in C# I am not really a C# programmer.  Consequently I decided to use VB and rely on my skills of reading C# code and translating it into VB code.  Luckily some of the examples in the OpenXML 2.0 SDK are VB based.

As I do not have a copy of Visual Studio I opted for the Express versions (Microsoft Express Tools) specifically Visual C# Express 2008 and Visual Basic Express 2008.  

OpenXML files are compressed wrappers for several files and folders.  These outer wrappers are called packages.  It is necessary to be able to view openXML packages in their natural environment (i.e. Office 2007 or later) and then to be able to view the "insides" of these packages to better understand how they work. I already have Office 2007 installed so I had a tool for generating documents that I could reverse engineer.  

OpenXML documents can be opened by Winzip however the following process is required:

  1. Open WinZip
  2. Open the openXML document as an archive
  3. Select the element of the document to be viewed
  4. Right Click and open in either Notepad or an XML viewer

Although I have Winzip I felt that this is a cumbersome process.  A little "googling" revealed a small utility that allows the user the view the insides of a package.  This is called, strangely, PackageExplorer.

Armed with these basic tools I set forth on the expedition of building my first OpenXML package.

Filed under  //   C#   Microsoft   Microsoft Express   Office 2007   OpenXML   OpenXML SDK 2.0   Package Explorer   SPSS   VB   Visual Studio   WinZip