Share via


WordImporter.Import Method

InfoPath Developer Reference

Imports the specified Microsoft Office Word 2007 document.

Version Information
 Version Added:  InfoPath 2007

Syntax

expression.Import(srcPath, destPath, vfShowUI)

expression   An expression that returns a WordImporter object.

Parameters

Name Required/Optional Data Type Description
srcPath Required String The path to the Office Word 2007 document.
destPath Required String The path to the folder which will contain the form template files of the converted Office Word 2007 document.
vfShowUI Required Boolean Shows the user interface while importing.

Return Value
String

Remarks

If the WordImporter is automated, the

vfShowUI

parameter is ignored.

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, a Office Word 2007 document named "Name.docx" is imported as 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) MessageBox.Show(ConvertResult)

oConverter.UnInitialize()

In the following example, a script is used to convert a 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