WordImporter Object

InfoPath Developer Reference

Allows Microsoft Office Word 2007 documents to be imported into InfoPath and converted into form templates.

Version Information
 Version Added:  InfoPath 2007

Remarks

For information on how to import an Office Word 2007 document into Microsoft Office InfoPath 2007 using the InfoPath design user interface, see Convert a Word document to an InfoPath form template.

The form template created as the result of the import process is not a single form template (.xsn) file. The folder specified by the

destPath

will contain the various form template files. Right-click the manifest.xsf file and click Design, then save the form template as an InfoPath Form Template (*.xsn) type. For more information about the form template files, see About Form Template Components.

This interface, object, member or enumeration is provided by the InfoPath design environment. A reference must be set to the Microsoft Office InfoPath Designer 2.0 Type Library, located at C:\Program Files\Microsoft Office\Office12\IPDESIGN.DLL.

This object or member is used for extending the InfoPath application and is not intended to be used directly from your form code.

Example

In the following example, an Office Word 2007 document named "Name.docx" is imported as one or more form template files to the "NewForm" folder in the temp folder on the local drive. This Visual Basic code requires a reference to the Microsoft Office InfoPath Designer 2.0 Type Library (IPDESIGN.DLL) and an Imports XDocsDesigner statement at the top of the form code.

Visual Basic
  Dim ConvertResult As String
Dim oConverter As XDocsDesigner.WordImporter = New XDocsDesigner.WordImporter
oConverter.Initialize()
ConvertResult = oConverter.Import("c:\temp\Name.docx", "c:\temp\NewForm", False)
oConverter.UnInitialize()
MessageBox.Show(ConvertResult)

In the following example, a script is used to convert an Office Word 2007 document named "Name.docx" to form template files in the "NewForm" folder in the temp folder on the local drive.

JScript
  // JScript source code

var oFileObject = new ActiveXObject("Scripting.FileSystemObject"); var strSourcePath = "C:\temp\Name.docx"; var strDestPath = "C:\temp\NewForm";

WScript.Echo("Creating the object..."); var oConverter = new ActiveXObject("InfoPath.DesignerWordImport.2");

WScript.Echo("Initializing..."); oConverter.Initialize(); try { WScript.Echo("Importing..."); var strMessage = oConverter.Import(strSourcePath, strDestPath, true); } catch(e) { WScript.Echo("Error: " + e.message); }

WScript.Echo("Result was: " + strMessage);

oConverter.UnInitialize();

See Also