Using the InfoPath to Word Wizard [InfoPath 2003 SDK Documentation]

Applies to:

Microsoft Office InfoPath 2003 Service Pack 1

The InfoPath to Word Wizard included with the Microsoft Office InfoPath 2003 Software Development Kit (SDK) allows you to create a special version of a form—called a print view—that is designed specifically for printing the form. You can further control the way your forms print by designing and designating print views for use in Microsoft Office Word 2003.

To create a print view for Word, you must have access to an existing Extensible Stylesheet Language Transformation (XSLT) file that transforms Microsoft Office InfoPath 2003 form data into a Word document. The InfoPath to Word Wizard makes it easy to create an XSLT based on your form.

The file name of the InfoPath to Word Wizard is Wizard.hta. The file is located in the <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\WordPrint folder. To use the InfoPath to Word Wizard, follow the instructions provided in this topic.

Important  Due to an error in the setup program, you must manually register the html2xhtml.dll and ImageDecode.dll files before the InfoPath to Word Wizard will work correctly. The html2xhtml.dll file is located in the <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\ folder. The ImageDecode.dll file is located in the <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\WordPrint folder. To manually register each file, open the Command Prompt window, change directories to the folder that contains the file, and then issue the following command: Regsvr32 <dllname>

Use the InfoPath to Word Wizard to design a print view specifically for Word

Follow these steps to create an XSLT file to be used as a view that will designate Word to print your form.

  1. Double-click Wizard.hta to start the InfoPath to Word Wizard. By default, Wizard.hta is located in the <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\WordPrint folder.

  2. Click Next.

  3. Click Browse. Select your form template (.xsn) file or the XML Schema (.xsd) of the form template and then click Open.

  4. Click Next.

  5. Click Open Word 2003.

    Word opens with a blank document that has the form's XML Schema attached. Use the XML Schema task pane to lay out the XML elements as you would like them to be printed. Click Save on the File menu when you are finished.

  6. Click Exit on the File menu.

  7. Activate the InfoPath to Word Wizard. Click Next.

  8. Click Browse. Select the Word document that you created to represent your print view and then click Open.

  9. Click Next.

  10. Click Finish.

Add the print view designed specifically for Word to your form

Follow these steps to add the print view designed for Word to your form.

  1. In design mode, click Manage Views on the View menu.

  2. Under Actions in the Views task pane, click Add Print View for Word.

  3. Follow the instructions in the Add Print View for Word Wizard to specify the XSLT file you want to use for the Word-based print view.

  4. In the Select a view list in the Views task pane, click the view for which you want to designate the Word-based print view, and then click View Properties.

    Note  If the Views task pane is closed, click Manage Views on the View menu to open it.

  5. Click the Print Settings tab.

  6. In the Select an existing view to use when printing this view list, click the Word-based print view.

Use Word to print a batch of forms

A Microsoft JScript file, PrnInWord.js, that allows you to silently print an InfoPath form in Word, is included with this SDK in the <drive>:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\WordPrint folder. PrnInWord.js is designed to be called from the command prompt or from a batch file. PrnInWord.js requires two parameters: the name of the form to print and the name of the XSLT file to apply.

The syntax of PrnInWord.js is as follows:

PrnInWord.js <form name> <xslt name>

Known issues with the InfoPath to Word Wizard

You may encounter one or more of the following issues when using the InfoPath to Word Wizard to create a Word print view. Some of these issues occur because InfoPath and Word differ in how they support XML data. Other issues are simply limitations of the wizard.

Multiple schemas not supported   If your InfoPath solution contains multiple schemas, such as for secondary data sources, these schemas may not appear in Word, even though they are available in InfoPath.

Repeated node names not supported   Node names that appear twice in the schema may not appear in Word.

Attributes not displayed in Word print view   Word does display the contents of attribute fields in the document. The XML stylesheet created by the InfoPath to Word Wizard must be edited manually to support the display of attribute fields.

Unusual Repeating Table setup in Word   If text not associated with a repeating field is located inside a table cell, the InfoPath to Word Wizard might produce unexpected results. Only fields that repeat should be part of a table that is tagged with a repeating field.

Alignment within a table cell lost  Alignment that is on a table cell, but not on the text itself, may be lost. You should always set alignment on the area that is marked with XML structure, not on the cell itself.

Word print view not updated after schema changes  If you update the schema that is attached to your form, you must run the InfoPath to Word Wizard to update the Word print view.

Multiple columns not supported   The InfoPath to Word Wizard does not support creating Word print views that contain more than one column. You can add multiple columns by editing the XML stylesheet generated by the InfoPath to Word Wizard.

Invalid schema errors displayed in Word   Word may flag portions of the schema as if it contains errors. You can safely ignore these warnings.

Print settings are lost   The InfoPath to Word Wizard does not save any settings located on the Print tab of the Options dialog box.

Images entered in Word are lost   Images that are part of the Word document, but not part of the InfoPath form, are not printed. To add images to your Word print view, they must be included in the form template (.xsn) as resource files. They must also be referenced by their filename in the XML stylesheet (.xsl) file.

Default images are not printed   Default images are not printed when printing a Word print view.

Frames not supported   The InfoPath to Word Wizard does not support creating Word print views that contain frames.

Repeating Sections not differentiated   If a section is used twice in the same Word document, the InfoPath to Word Wizard will not distinguish between the sections. You can work around this issue by manually creating an XML stylesheet with different templates.

ADO connections not handled by Word  Data connections may appear to Word as multiple data sources. Word will not automatically download data associated with those data connections.

Line breaks in plain text fields ignored   Plain text fields with line breaks will not appear on one line in the Word print view. You can work around this problem by adding the following code to your XML stylesheet:

<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
     function convertCRLF(InputString) 
     {
          var reCRLF = new RegExp("\r\n", "g");
          return InputString.replace(reCRLF, "<br>");
     }
]]>
</msxsl:script>
<xsl:template match="/">
     <xsl:value-of select='user:convertCRLF(string(//field1))'/>
</xsl:template>