Presenting InfoPath 2003 SP-1


In this chapter, you will learn how to

  • Describe what you can accomplish with InfoPath
  • Describe how InfoPath works in general
  • Describe how InfoPath interacts with other Microsoft Office applications
  • Start InfoPath and open a sample form in data entry mode
  • Switch between InfoPath data entry and design modes
  • Open the Microsoft Script Editor and view JScript form programming code.
  • Describe how the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET enables programming forms with Visual Basic .NET or Visual C#


To work through this chapter

  • You should be competent in managing Microsoft Windows XP Home or Professional Edition or Microsoft Windows 2000 Professional.
  • You should have experience using recent versions of Microsoft Office applications, such as Microsoft Word and Microsoft Excel. Familiarity with Microsoft Office System 2003 applications is helpful but not essential.
  • You should have Microsoft Office InfoPath 2003 Service Pack 1 (SP-1) installed on your computer. For more information about SP-1, go to Prior to installing SP-1, you must have installed the InfoPath 2003 release version from a network installation folder or the retail packaged version.
  • Optionally for this chapter, you should have the sample files from the CD that accompanies this book installed in your C:Microsoft PressIntroducing InfoPath 2003Chapter## folders. The section About the Companion CD in the Introduction describes the sample file installation process.

The original purpose of Extensible Markup Language (XML) was to define new text-based document formats for the World Wide Web. Subsequently, XML evolved into a language for describing almost any type of data so its been responsible for an information-processing revolution. XMLs capability to represent common data typessuch as rows from a database or cells in a spreadsheetas plain-text, human-readable documents has so dramatically increased its use in the information technology industry that its become the world-wide standard for exchanging data between software applications running on all popular operating systems. As a testament to XMLs popularity, searching for XML returned more than 30 million hits when this book was written.

Todays most common use of XML is behind the scenes transferring data between servers and, to a lesser extent, between servers and client PC applications. XML provides the foundation for new and rapidly growing software markets, such as Web services, weblogs, and workflow automation.

XML isnt dependent on a specific computer language or operating system. Almost all recent commercial software applications and development platforms support at least basic XML processing, but very few information workers have manipulated an XML document in its original format. Most PC users encounter their first .xml file or one of the other x-files (.xsd, .xsl, and the like) by opening the file in Internet Explorer, often accidentally . Making sense of complex XML documents is a formidable challenge for XML neophytes.

The objective of Microsoft Office InfoPath 2003 is to make creating and editing XML document files on the desktop or laptop as common as working with Microsoft Word, Excel, Outlook, and Access. InfoPath is certain to cause a dramatic increase in the use of XML by information workers and, as a consequence, their overall productivity.

The Benefits of InfoPath

InfoPath 2003 is a new member of the Microsoft Office System that enables ordinary PC users to collect information by typing data or making selections in an easily designed, simple-to-use, HTML-based form and save the information in a XML document file that any other XML-enabled application can process. Your first reaction to this understatement might be: So what? There are plenty of HTML form design programs available, including Microsoft FrontPage, and I can create data entry forms in Microsoft Access, Excel, and Word.

Here s the key to InfoPath s success: Microsoft designed InfoPath for capturing semi- structured data in an intuitive form with the familiar Office-standard user interface (UI). Semi-structured means that the XML data that you create or edit doesn t need to adhere to a rigid data model, such as the row-column organization of an Excel worksheet or the relational data structure of an Access or Microsoft SQL Server database. If you design your own XML data document, you can choose to add or omit optional information, include text that s formatted with HTML tags, and specify whether parts of your form represent single or multiple information items. InfoPath forms ensure that the XML data file you save complies with XML formatting rules.


Imposing structure with predefined documents
If you base your form on someone else s XML data document design for a typical paper business form, such as a purchase order or invoice, you probably won t have the freedom to alter the document s design or apply HTML tags to the data. In this case, the XML data is called a (fully) structured document

InfoPath s capability to capture semi-structured data lets you combine in a single form related data that you or your coworkers presently might collect from a combination of Microsoft Outlook e-mail messages, Word documents, Excel worksheets, Access or SQL Server 2000 queries, HTML pages, and text files. InfoPath increases productivity by eliminating multiple cut-and-paste operations and time-consuming , error-prone data retyping. You can send the XML document as an e-mail attachment to InfoPath-equipped coworkers, who add and edit data or approve the data and then return the document to you for final processing. Figure 1-1 illustrates a sample InfoPath form opened in Outlook 2003. If the recipient has InfoPath installed and network access to the form s file, clicking the ChangeOrder1.xml file Attachments link opens the form for editing.

click to expand
Figure 1-1: E-mailing a form as an attachment to a manager or customer for approval is a common InfoPath scenario.

InfoPath s ability to route data documents makes it easy to set up formal, multistep workflow processes without writing any programming code. As an example, assume that you re supervising a new product-development team and must send a comprehensive monthly status report to management. You maintain budget data in an Access database. Team members send you Excel worksheets with their time and cost expenditures, which you integrate into a master worksheet. You receive e-mail messages from team members that contain brief narratives of progress during the month, list issues outstanding, and provide the percentage completion of individual tasks . You have a Microsoft Word template into which you copy and paste data from Access queries, the master worksheet, and parts of e-mail messages; edit the content; and send the .doc file as an e-mail attachment to your manager and the accounting department. It takes you five hours or more to assemble and edit the incoming m lange of data.

An InfoPath form, such as the sample Status Report form you open in this chapter s later section Touring InfoPath and fill out in Chapter 2, lets individual team members do all the work. You e-mail the form to the first team member, who contributes her status information to the form, and then passes it on to the next person to add his data, and so on. Each team member can see previous members contributions, which avoids data duplication. You receive the final version, look it over, and e-mail it to management. InfoPath reduces your five hours or more of monthly agony to a few minutes of checking numbers and performing minor edits. The accounting department s enterprise resource planning (ERP) application is XML-enabled, so the monthly numbers go directly to the general ledger without manual intervention.


Signing Forms with Digital Certificates:
To assure your form s authenticity, you can add a digital signature to the entire form or to specific elements of the form called data blocks. Team members can sign the data they contribute, and you can co-sign or counter-sign the content they add. Chapter 11, Setting Form Template and Digital Signing Options, shows you how to add digital signatures to forms and code-signing certificates to templates. If someone tampers with the form you sign, InfoPath notifies the form s recipient that its digital signatures are invalid.

Here are a few additional features that make InfoPath a unique and highly productive form design and data capture application:

  • You don t need to be an XML expert to use InfoPath or design InfoPath forms. The familiar Office UI, task panes, wizards, and drag-and-drop design tools shorten your learning curve.
  • It s a simple process to design a new form based on a copy of an existing XML document or the design specification for a document, which is called an XML schema . Most of this book s sample forms are based on sample XML documents. If you don t have an XML schema for the document, InfoPath generates one for you automatically.
  • The Data Connection Wizard guides you through the steps of generating data entry forms from Access (Jet) and SQL Server database tables. Alternatively, you can receive data from and submit data to XML Web services.
  • You can quickly define the structure of a new XML document in a graphical task pane and then design the form based on the XML schema that InfoPath creates for you.
  • InfoPath forms validate data that users enter before saving the underlying XML document. By default, InfoPath checks the data against the document s design as defined by its schema. You can highlight incorrect entries with conditional formatting and apply custom data validation rules without writing programming code.
  • It s easy to post a static version of a form to a Web site by exporting it in .mht (Single-File Web Page) format. The .mht file doesn t include the XML document, so the recipient can t edit the form.
  • Most applications that understand XML can process the XML documents you create or edit in an InfoPath form. The XML standard isn t tied to any programming language or operating system.
  • You don t need to be a programmer to design and deploy useful InfoPath forms. However, form programming lets you implement many advanced form features and add custom business logic to forms.
See Also  

Part II, Designing InfoPath Forms, provides detailed explanations of the form design process and step-by- step instructions for designing simple and complex InfoPath forms. Part III, Working with Databases and Web services, illustrates use of the Data Connection Wizard. Part IV, Programming InfoPath Forms, covers customizing advanced forms with Microsoft Visual Studio .NET 2003 or Microsoft Visual Basic .NET Standard Edition 2003 and the Visual Basic .NET programming language.

Understanding How InfoPath Works

The original goal of the developers of XML was to provide a way of separating content (data in XML format) from presentation (HTML text and formatting code) in Web documents. This distinction enables displaying the same data in multiple presentation formats ”typically browsers running on conventional PCs, handheld organizers, and cell phones. InfoPath forms follow the principle of separation of data and presentation. An InfoPath form combines an XML data document and a template; the template defines the presentation of the data for editing, messaging, and printing.

Another benefit of presentation independence is the ability to provide different views of the data in a single form. One form view might display summary data for multiple document parts , whereas an alternative view might show detailed information for a selected part. You also can design views that are optimized for different devices, such as Pocket PCs or even cell phones.


Defining forms, templates, data documents, and views
InfoPath s documentation doesn t always distinguish between forms, templates, data documents, and views. This book uses the term form to mean a combination of an XML data document, which you save as an .xml file, and an editing template (.xsn file). Form also refers to the static version sent as an e- mail attachment (refer to Figure 1-1) or exported in .mht format. A view is the HTML representation of a form; all forms have a default view. Chapter 3 describes the files used by an InfoPath form and how InfoPath creates views. Chapter 12 shows you how to send static and dynamic forms by e-mail.

Previewing a Sample InfoPath Form

InfoPath s UI is quite similar to those of other Microsoft Office System 2003 applications, which makes working with forms a familiar process. Figure 1-2 shows a simple contact form in data entry mode, also called edit mode or fill out a form mode.

click to expand
Figure 1-2: This simple InfoPath form enables capturing contact data.

Here s a list of the similarities and differences between the InfoPath 2003 and Word 2003 primary UI elements:

  • The InfoPath 2003 menu bar is almost identical to that of Word 2003; only Word s Window menu option is missing.
  • Most buttons on the InfoPath 2003 Standard toolbar correspond to those on the Word 2003 Standard toolbar. InfoPath SP-1 has additional Design and Format Painter buttons borrowed from Microsoft Office Access 2003.
  • InfoPath and Word use the standard Windows shortcut keys, such as Ctrl+O to open a form and Ctrl+P to print a form.
  • Three InfoPath task panes ”Search Results, Help, and Clip Art ”are common to other Office System 2003 applications. The others ”Find, Replace, Font, and Bullets And Numbering ”assist users with InfoPath data entry operations.
  • The InfoPath work area is an HTML-based form. The simple Contacts example form shown in Figure 1-2 uses text boxes inside table cells for data entry. InfoPath offers many other HTML control types, such as option (radio) buttons, check boxes, ordered and unordered lists, and a special rich text box control to which you add HTML-formatted text.
  • The status bar at the bottom of the Contacts form differs from Word by showing the path to the form s template.

Saving Data as XML Files

 SP-1   When you open an empty InfoPath form, you re opening the default view of a form template and an in-memory (cached) XML document that contains no data. As you enter data in the form, InfoPath adds the information to the cached document. Saving the form as DataDocName.xml writes the cached information to a disk file in a folder (My Documents, by default). Alternatively or additionally, you can store the XML file in a shared folder of a file server, POST it to a Web site, or add it to a Windows SharePoint Services form library. InfoPath SP-1 s AutoSave/AutoRecover features prevent losing a data document in the event of a power failure or hardware problem.

Listing 1-1 shows the Oakmont Contacts.xml file with the data entered in Figure 1-2. The first line is called the XML declaration and is present in all InfoPath and most other XML documents. The listing excludes XML content (called processing instructions) that s specific to InfoPath.

Listing 1-1: The XML content of a contacts list with a single contact entry.

Carla Gallaway

13822 Outlet Drive

Olathe KS 66061-2425 (541) 342-2780  

XML files are text-based files that you can open and edit in Notepad or read in Internet Explorer. Figure 1-3 shows a slightly modified version of Figure 1-2 s XML data document open in Internet Explorer 6.0. Applications other than InfoPath disregard the processing instructions (PIs), which begin with < ?mso-infoPathSolution and end with ? >. This means that almost every XML-enabled application running under any computer operating system can process an InfoPath data document.

click to expand
Figure 1-3: Internet Explorer 6.0 will display an InfoPath XML data document if it s modified to prevent InfoPath from opening it automatically.


Viewing InfoPath XML files in Internet Explorer
InfoPath XML data files open in InfoPath when you choose Open With, Internet Explorer from the file s shortcut menu. Installing the sample files creates original and modified versions of Oakmont Contacts.xml in your C:Microsoft PressIntroducing InfoPath 2003Chapter01 folder. The modified version will open in Internet Explorer.

XML content consists of pairs of start and end tags, such as < lastName > and < /lastName >, to describe the content between the tag pairs, which define XML document elements. Tag pairs that contain text information only are called leaf elements or leaf nodes; the < firstName > through < eMail > nodes are leaf nodes. The capability to choose your own descriptive tag names for your data is what makes XML extensible and ”more importantly ” self-describing . Unlike HTML, which is very forgiving of missing tags, XML requires each start tag to have a corresponding end tag or use the shorthand version of an empty tag: < tagName / >. As an example, HTML allows a stand-alone < BR > (break) tag, XML requires empty < BR / > or < br / > tags . XML tag names are case-sensitive, so a < lastName > start tag won t match a < LastName > end tag.

See Also  

Chapter 3 describes in detail XML 1.0 data documents and the related XML dialects that InfoPath uses to define templates and views and how InfoPath interprets processing instructions.

Integrating InfoPath with Other Applications

InfoPath s use of XML as its data exchange format means that XML-enabled applications, such as Microsoft Word 2003 and Excel 2003, can import and edit InfoPath data files. You also can view, update, and save information stored in databases or retrieved from XML Web services. The following sections provide brief descriptions of InfoPath s most important interoperability features.

Working with Office Excel and Word 2003

You can import simple InfoPath XML data documents to Excel 2003 Professional Edition workbooks and assign XML leaf element text to worksheet list columns automatically. Assigning individual elements to columns is called mapping . You must make minor changes to Excel s default mapping to enable exporting the XML data. Figure 1-4 shows a longer version of the Oakmont Contacts.xml file mapped to an Excel 2003 list.

click to expand
Figure 1-4: This is an InfoPath XML data document imported to an Excel 2003 Professional list.

XML files that you modify in Excel and save as XML Data (.xml) won t open in InfoPath automatically, because Excel strips the processing information from the file.

Opening the same Contacts.xml file in Word 2003 Professional Edition generates the XML document view shown in Figure 1-5. Unlike Excel, saving an edited Word XML document doesn t remove the PIs, so the saved document opens in its original InfoPath template.

click to expand
Figure 1-5: This InfoPath XML data document has been imported to Word 2003.

Alternatively, you can import an InfoPath schema file (Schema.xsd) into Word s Schema Library and add data to elements you select from the XML Structure task pane. Word 2003 XML documents you create from scratch with imported schemas and save as .xml files don t include InfoPath PIs.


Cutting and pasting elements between Office applications
You can copy formatted text and tables in InfoPath rich text boxes and paste these elements into Microsoft Word version 2000 and later documents, and vice versa. Copying and pasting cells from Excel version 2000 and later worksheets into rich text box tables (and the reverse) also works. The extent to which formatting is preserved depends on the version of Word or Excel you use. The section Adding Tables to Rich Text Boxes, in Chapter 2, describes the cut-and-paste process in detail.

Using Access or SQL Server Tables as Data Sources

InfoPath forms aren t a fully qualified substitute for Access data entry forms, but they offer unique advantages. You can save an XML data document that you route to others for action or approval, or you can send the document to a workflow management application, such as Microsoft BizTalk Server 2004. Integration with BizTalk Server 2004 is beyond the scope of this book, but you can learn more about this new Windows Server System application at .

InfoPath s Data Connection Wizard lets you select tables from Access (Jet), Microsoft SQL Server Desktop Engine (MSDE) 2000, or other SQL Server 2000 editions to create forms for selecting, adding, editing, and deleting records. The Data Connection Wizard lets you specify the relationships between related tables to generate forms that emulate Access forms and subforms. Clicking Finish in the last Data Source Setup Wizard screen generates an empty template with a combined query and data entry view.

Figure 1-6 illustrates a sample data entry and editing form for Access 2003 s NorthwindCS MSDE database. Entering a valid value in the Order ID text box and clicking the Get Order Data button displays an Orders record and its related Order Details records at the bottom of the form. Clicking the New Order button lets you add a new Orders record and multiple Order Details records. InfoPath handles updates to records with SQL Server identity or Jet autonumber columns without a hitch. This feat might surprise database developers who ve worked extensively with identity or autonumber fields.

click to expand
Figure 1-6: This InfoPath form emulates an Access form-subform combination.

The Northwind Traders Order Entry And Editing Form template introduces four InfoPath controls that don t appear on the Contacts form:

  • Date pickers Adjacent to the three date text boxes. When you click the date picker button a calendar opens to let you select a date.
  • Drop-down list boxes In this form, display data based on adjacent primary key values, such as a customer name from the customer code. Drop-down list boxes let you select from value/display- name pairs.
  • Expression boxes In this form, calculate the Extended line item values. Expression boxes most commonly perform calculations with numerical values, but also can manipulate character values.
  • Buttons Used for initiating built-in or custom InfoPath actions. The form s buttons execute built-in Run Query, Submit, and New Record actions.

Here s the most interesting fact about this data entry form, which also implements InfoPath s data validation features: it doesn t require a single line of programming code.

See Also  

Chapter 6, Adding Basic Controls and Lists, describes how to take advantage of InfoPath s repertoire of smart HTML controls. Chapter 8, Validating Form Data, shows you how to implement data validation. Chapter 13, Connecting Forms to Databases, explains how to use tables as a form s primary data source and populate drop-down list boxes from secondary data sources.

Adding Data Documents to a SharePoint Form Library

If you have access to a Windows SharePoint Services site running under Windows 2003 Server, you can publish your InfoPath template and its associated XML data documents to a form library. Figure 1-7 shows a sample form library, which contains data files for seven NorthwindCS orders. A SharePoint site is the most convenient way to make an InfoPath form accessible to coworkers and group the form s XML data documents in a single shared location.

click to expand
Figure 1-7: This demonstration Windows SharePoint Services form library lists InfoPath data documents for sample orders.

The form library is the default location for saving new and edited data files. You can also save copies of the data files to a shared folder on a file server or on your own computer.

See Also  

The section Publishing Templates to Windows SharePoint Services Form Libraries, in Chapter 11, gives you step-by-step instructions for creating a new form library and publishing a form to the library. Visit for more information about Windows SharePoint Services, the successor to SharePoint Team Services.

Connecting Forms to XML Web Services

Web services have recently become a major contributor to the widespread adoption of XML technologies. Web services deliver an open standards approach to transferring data between networked computers running different operating systems and programming environments. For example, a properly designed ASP.NET Web service created with Microsoft Visual Studio .NET and running under Windows 2000 or later can interoperate with Java-based Web services or Web service clients running under various UNIX flavors, and vice versa. Every major player in the software development platform, database management system, and enterprise-scale application businesses now supports Web services technologies at varying levels of sophistication.

One of Microsoft s objectives for InfoPath 2003 was to make it easy to connect to and collect data from XML Web services. InfoPath s Data Connection Wizard offers the option of connecting to a Web service and creating an InfoPath schema from it. Creating a form with a Web service connection is very similar to using database tables as the form s data source. Figure 1-8 is the Web service version of the form shown in Figure 1-6. Chapter 14, Designing InfoPath Web Service Clients, and Chapter 17, Writing Advanced Event Handlers, show you how to design forms that connect to an ASP.NET Web service to retrieve and update information in an SQL Server or MSDE 2000 database.

click to expand
Figure 1-8: This InfoPath XML Web service client that you develop in Chapter 17 emulates Figure 1-6 s form and adds an expression box to display the running sum of the Extended column.

Touring InfoPath

The preceding examples of InfoPath forms demonstrate what you ll be able to do with InfoPath after working your way through the design- related chapters in Part II and Part III. Now it s time to launch InfoPath and give it a test drive with one of InfoPath s sample forms.

InfoPath s Guided Tour

To watch an animated (Macromedia Flash) preview of how InfoPath works, you can take the Microsoft Office InfoPath 2003 Tour by following these steps:

  1.  SP-1   Choose Start, (All) Programs, Microsoft Office, Microsoft Office InfoPath 2003 to open the Fill Out a Form dialog box.
  2. Click the Take A Tour Of InfoPath link at the lower right of the dialog box to open the first tour page. Download the Macromedia Flash Player, if necessary, and then click the Start Tour button. The Flash presentation eventually displays the What Is InfoPath? page.
  3. Click Continue twice to display the InfoPath Tour Contents page. You can return to the Contents page at any time by clicking the Contents button at the top of a page.
  4. Click the Filling Out Forms link, which leads to a page of the same name .
  5. Click the Play button to start an animated segment.
  6. When the segment completes its animation cycle, click the Return link and then the Continue link. Filling Out Forms, for example, has 7 animated segments. The Designing Your Own Forms topic has 10 segments.

Opening a Sample InfoPath Form

Installing InfoPath 2003 adds 25 sample forms to your Program FilesMicrosoft OfficeOffice11InfForms1033 folder, if you ve installed the U.S. English version. (The locale code differs for other regions and languages.) The sample forms emulate paper business forms and share a common design theme. To launch InfoPath and open one of the simpler forms, follow these steps.

Launch InfoPath and open a form

  1.  SP-1   Choose Start, (All) Programs, Microsoft Office, Microsoft Office InfoPath 2003 to launch InfoPath, which opens the Fill Out A Form dialog box, also called the dashboard.
  2. Click the Sample Forms link under the Form Categories heading to display icons for the 25 sample out-of-the-box forms, as shown on the next page.

    click to expand

  3. Scroll to the end of the list, double-click the Status Report item to close the Fill Out A Form dialog box and display the form in InfoPath s work area, with the default Standard and Formatting toolbars visible. JScript code in the form s template automatically sets the date picker s value to your system date.
  4. Maximize the window, if necessary, to display the topmost elements of the form. The sample forms are designed to fill an 800 “by-600-pixel window with the task pane visible.
  5. If the task pane isn t open, press Ctrl+F1. Click inside the rich text box under the Summary heading to enable the Formatting toolbar s buttons , as shown here:

    click to expand

  6. In data entry mode, the Formatting toolbar is fully enabled only for data entry in rich text boxes. Rich text boxes also enable three buttons of the Standard toolbar: Insert Hyperlink, Insert Table, and Insert Picture.

Using Design Mode to Create or Modify Forms

To display the sample Status Report form in design mode, click the Design This Form button, or choose Tools, Design This Form. If you ve worked with Microsoft Access, you ll notice that InfoPath s design mode corresponds to Access data page design view. In design mode, InfoPath s Standard toolbar gains Preview Form and Design Tasks buttons, and the Formatting toolbar is enabled, as shown in

Figure 1-9. When you open a sample form in design mode, the default template name is Template1.

click to expand
Figure 1-9: This is the sample Status Report form opened in InfoPath s design mode.

The Design Tasks task pane, which opens when you enter design mode, displays links to other task panes and a wizard for the five basic steps in the form design and deployment process: Layout, Controls, Data Source, Views, and Publish. In Part II, an entire chapter is devoted to each task.

Programming Forms with VBScript or JScript

Most Office System applications use Microsoft Visual Basic for Applications (VBA) as their application programming language. Office s Visual Basic Editor (VBE) makes it easy to add or modify macros or, in the case of Access, code behind forms or in modules. InfoPath 2003 departs from this norm by using Microsoft JScript or Microsoft Visual Basic Scripting Edition (VBScript) and the Microsoft Script Editor (MSE) as the default code editing tool to customize the behavior of forms. JScript is InfoPath s default scripting language, but you can change the default to VBScript. The next section, Programming Forms with Visual Basic .NET Code describes this book s preferred alternative to scripting InfoPath forms. Fortunately, you don t need to write custom code to create useful InfoPath forms, as demonstrated by the database and XML Web service examples in the section Integrating InfoPath with Other Applications, earlier in this chapter.

If you re a competent VBA programmer, adapting to VBScript, which is a subset of VBA, is reasonably easy. However, the sample forms and most InfoPath programming examples use JScript, Microsoft s implementation of ECMAScript ”originally known as Netscape JavaScript. You need basic JScript skills to understand the code behind the sample forms and take advantage of their array of standard functions in the script that you add to your forms. Moving from VBA and the VBE to JScript and MSE isn t a piece of cake, and debugging complex script is difficult at best.

With the Status Report form open in design mode, choose Tools, Script, Microsoft Script Editor or press Alt+Shift+F11 to open MSE and display the JScript functions behind the form in a new window. Figure 1-10 shows MSE with the Project Explorer and Properties windows hidden to expose more of the JScript code.

click to expand
Figure 1-10: MSE displays only a small part of the code behind the sample Status Report form in this window.

Form events, such as opening a form, execute JScript functions called event handlers . The Document Outline window lists all event handlers and other functions for the template. The function XDocument::OnLoad(oEvent) event handler corresponds to VBA s Private Sub Form_Load event handler. This function inserts the system date in the date picker control at the top of the form.

At this point, close the MSE window to make InfoPath s design window active, and then close the design window to return to the Status Report form in data entry mode. Don t save any accidental changes.

Programming Forms with Visual Basic NET Code

One of InfoPath SP-1 s most important new features is the ability to create InfoPath Form Projects, which substitute managed Visual Basic .NET or Visual C# code behind forms for VBScript or JScript. It s probably easier for most Office developers and Visual Basic 6.0 coders to adapt to Visual Basic .NET than learn JScript. Your expenditure of time and energy learning Visual Basic .NET will deliver a much higher return on investment than a transition to JScript or downlevel VBScript, which some analysts call Microsoft s forgotten language.

To take advantage of InfoPath Form Projects, you must have Microsoft Visual Studio .NET 2003 Professional edition or higher, or the $99 (estimated retail price) Visual Basic .NET 2003 Standard Edition, and the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET installed on your development computer. You can download the Toolkit from a link on the InfoPath page at understanding/infopath/ . Users of forms with managed code must have the Microsoft .NET Framework 1.1 runtime version, available at no charge, installed on their computer.

Installing the Toolkit adds a Microsoft Office InfoPath Project node to Visual Studio .NET s New Project dialog box, and a Visual Basic Projects subnode with an InfoPath Form Template icon in the Templates folder. If you have the Visual Studio .NET Professional edition or higher, you ll also see a Visual C# subnode, as shown in Figure 1-11.

click to expand
Figure 1-11: Installing the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET adds these nodes and an InfoPath Form Template icon in the New Projects dialog box.

Chapter 15, Introducing InfoPath Form Template Projects, describes the Toolkit installation process and how to write simple event-handling procedures with Visual Basic .NET. The remaining two chapters of Part IV demonstrate increasingly complex coding techniques. Figure 1-12 shows the FormCode.vb window of the NWOrdersWSProject example, which Chapter 17, Writing Advanced Event Handlers, describes in detail. InfoPath automatically generates event-handling procedures with starting code for you. In most cases, you can import VBScript event-handling code into the event handlers and run the project with very few, minor changes.

click to expand
Figure 1-12: This Visual Studio .NET 2003 FormCode.vb window displays part of the Visual Basic .NET code for the sample XML Web service client of Figure 1-8.


Microsoft Office InfoPath 2003 SP-1 is the newest member of the Microsoft Office System 2003. The primary purpose of InfoPath is to create forms for capturing and saving semi-structured or fully structured data in the open -standard XML 1.0 format. InfoPath s user interface is very similar to that of Word 2003; InfoPath shares many features that are common to all Office 2003 applications, such as task panes and AutoSave/AutoRecover.

An InfoPath form has two components : a template that defines the design of a form and an XML data document that contains the information you capture. You can e-mail forms with Microsoft Outlook, export the XML data to an Excel worksheet, and import the XML data into an Excel 2003 list or an XML view of a Word 2003 document.

InfoPath has two basic operating modes: data entry for filling out and saving forms and design for creating or modifying and saving form templates. The Fill Out A Form dialog box, which opens automatically when you launch InfoPath, makes it easy to open a recently used form or one of the 25 InfoPath sample forms. In addition to form creation, InfoPath includes functionality for Windows SharePoint Services integration, connecting to Access (Jet) and SQL Server databases or XML Web services, offline form editing, form merging, and digital signatures.

 SP-1   You can design and deploy production InfoPath forms without programming, but you might find that you must add code to implement specialized business logic. You add JScript or VBScript code to forms in the Microsoft Script Editor. The sample forms use JScript, which is InfoPath s default programming language. InfoPath SP-1 and the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET enable programming forms with Visual Basic .NET or Visual C#.



Must everyone who needs to fill out forms have a valid InfoPath 2003 license?

yes. there is no reader program that can be used to read and fill out a form; you must have infopath installed to do that. however, infopath does support exporting to the single-file web page (.mht) format, also called web-archive (single file), so you can create a static view of a form that can be viewed in a web browser.


Can people who don t have Office System 2003 licenses use InfoPath?

yes. you can purchase the retail, packaged version of infopath 2003 from any authorized microsoft distributor or retail software outlet and upgrade it to sp-1. you can download and install the microsoft office infopath 2003 toolkit for visual studio .net from the microsoft web site after you install the sp-1 upgrade.


Will InfoPath 2003 run on Tablet PCs?

yes. infopath 2003 includes a special ink control for hand-signing forms.


Is a version of InfoPath available for Pocket PCs?

not at this time.


Do I need experience writing VBA code to program custom InfoPath forms?

not if you re a jscript programmer or have vbscript experience. you need competency with vba, visual basic 6.0, or, preferably, visual basic .net to add managed code to infopath forms. visual c# is an alternative, but moving from vba or visual basic 6.0 to visual basic .net is a more practical choice for most office system developers.



Yes. There is no reader program that can be used to read and fill out a form; you must have InfoPath installed to do that. However, InfoPath does support exporting to the Single-File Web Page (.mht) format, also called Web-Archive (Single File), so you can create a static view of a form that can be viewed in a Web browser.


Yes. You can purchase the retail, packaged version of InfoPath 2003 from any authorized Microsoft distributor or retail software outlet and upgrade it to SP-1. You can download and install the Microsoft Office InfoPath 2003 Toolkit for Visual Studio .NET from the Microsoft Web site after you install the SP-1 upgrade.


Yes. InfoPath 2003 includes a special ink control for hand-signing forms.


Not at this time.


Not if you re a JScript programmer or have VBScript experience. You need competency with VBA, Visual Basic 6.0, or, preferably, Visual Basic .NET to add managed code to InfoPath forms. Visual C# is an alternative, but moving from VBA or Visual Basic 6.0 to Visual Basic .NET is a more practical choice for most Office System developers.

On Your Own

Heres an additional exercise for opening an InfoPath form and navigating between data entry and design mode, including previewing the form in design mode:

  1. Close and reopen InfoPath 2003.
  2. Use the Fill Out A Form dialog box to open one of the InfoPath sample forms as Form1.
  3. Use the Standard toolbars Design This Form button to switch to design mode.
  4. In design mode, choose Tools, Script, Microsoft Script Editor to open MSE.
  5. Explore a few of the supporting JScript functions below the three event-handling functions. (Most sample templates have JScript code.)
  6. Close MSE to return to design mode.
  7. Click the Preview Form button on the Standard toolbar to open the form for previewing.
  8. Click the Close Preview button.
  9. Close the Template1 window.
  10. Close the Form1 window to exit InfoPath without saving changes.

Introducing Microsoft Office InfoPath
Introducing Microsoft Office InfoPath 2003 (Bpg-Other)
ISBN: 0735619522
EAN: 2147483647
Year: 2006
Pages: 248
Simiral book on Amazon © 2008-2017.
If you may any questions please contact us: