What's New for Office 2003 Developers

 

Paul Cornell
Microsoft Corporation

December 9, 2002

Summary: Paul Cornell delves into Office 2003 Beta 1 and provides an overview, as well as examples and screenshots, of the many enhanced features for developers. (20 printed pages)

The next version of Microsoft® Office, code-named Office 2003, offers a wide array of solution development enhancements and options. Although Office 2003 is not scheduled to release until mid-2003, I'll provide you with a first look of some possibilities for Office 2003 solution developers.

Note   This month's column was written based on Office 2003 Beta 1 software. You can expect that Microsoft can (and will) change this information, as well as the screen shots provided.

Office 2003 for Developers: What Stays the Same?

One of the main questions that I've heard Office developers ask in online chats and in the newsgroups is whether Microsoft is removing the Microsoft Visual Basic® Editor and the Visual Basic for Applications (VBA) language from Office 2003 (one of the other main questions is whether Office 2003 will support Microsoft Visual Basic .NET and Microsoft Visual C#™ .NET; I will answer that question later).

In Office 2003, the Visual Basic Editor programming environment and the core VBA language remain essentially unchanged from Office XP. This means that Office XP VBA solutions that you create will be, for the most part, forward compatible with Office 2003. However, as you'll read later in this month's column, there will be some new tools that will allow you to write Visual Basic .NET code or Visual C# .NET code in Product Information for Visual Studio .NET 2003 and have the next version of Microsoft Word (code-named Word 2003) and the next version of Microsoft Excel (code-named Excel 2003) run the .NET code that you write.

Office 2003 for Developers: What's New?

Just because the Office 2003 Visual Basic Editor and the VBA language remain, for the most part, unchanged from their Office XP counterparts, this doesn't mean that there will be no Office 2003 developer innovation. Far from it! Office 2003 provides lots of improvements over Office XP solution development, including:

  • Expanded XML support in Word 2003 and Excel 2003, including object model programmability and the use of customer-defined XML schemas.
  • A new Office 2003 solutions model called smart documents.
  • "Visual Studio Tools for Office."
  • Significant smart tag enhancements.
  • List technology.
  • Office 2003 object model additions.
  • A new business-form oriented product code-named Microsoft "XDocs," which includes a programmable object model.
  • And much more!

XML Support in Word 2003 and Excel 2003

Word 2003 supports XML file creation, storage, editing, and XSL data transformation. In Microsoft Word 2000 and 2002, documents saved in HTML format had some islands of XML data saved within them, but you could not use these products to natively create or save XML documents. In Word 2003, you can save documents into several different XML document formats, including full-fidelity round-trippable Word documents conforming to the Microsoft Word XML document schema or other customer-defined XML schemas. You can even apply XSL transforms to XML data during save operations.

Creating an XML file based on a customer-defined XML schema is as straightforward as clicking New on the File menu, clicking New XML document, and following the directions in the new XML Structure task pane to attach an XML schema to the document and create structured XML content, as shown in Figure 1 and Figure 2.

click for larger image

Figure 1. The Word 2003 Templates and Add-Ins dialog box allows you to reference an XML schema to create an XML document in Word 2003 adhering to that schema.

click for larger image

Figure 2. Editing a customer-defined XML data file in Word 2003 using a default XSL transform.

For those already familiar with working XML and transformations, Word 2003 is built on Microsoft XML v5.0, giving you much of the power with which you are already familiar. You can insert chunks of XML anywhere in a Word document by using transformations to the Microsoft Word XML document schema or HTML and use MSXML schema validation to maintain the integrity of the data. With XML structure in a Word document, your solution can be more robust by locking down parts of a document to prevent editing or by enforcing the usage of specific fonts and formatting.

From an object model perspective, the Word 2003 XMLChildNodeSuggestion, XMLNamespace, XMLNode, XMLSchemaReference, and XSLTranform objects, and the XMLChildNodeSuggestions, XMLNamespaces, XMLNodes, XMLSchemaReferences, and XSLTransforms collections can be used to do things like access XML root nodes, XML namespaces, XML child nodes, XML schemas, and XSL Transformation files from Word 2003 XML documents.

For example, say you open the following XML file in Word 2003:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bookstore xmlns="schema.xsd">
    <book>
        <title>What's New for Office 2003 Developers?</title>
        <author>
            <first-name>Paul</first-name>
            <last-name>Cornell</last-name>
        </author>
        <price>49.99</price>
    </book>
</bookstore>

Assuming that the contents of the XML file were displayed as the active Word document, to programmatically access the contents of the last-name element, you could display the value Cornell by using the XMLNode object's SelectSingleNode property to access the last-name node with an XPath query, and then use the XMLNode object's Text property to display the value of the selected node, as follows:

...
MsgBox ActiveDocument.XMLNodes(1).SelectSingleNode _
    (XPath:="/ns1:bookstore/ns1:book/ns1:author/ns1:last-name", _
    PrefixMapping:="xmlns:ns1='schema.xsd'").Text
...

Another compelling Word 2003 XML feature is the ability to manually or programmatically include XML data in an existing document through the use of document fields. For instance, you may want to include in your document some XML data that is being continuously updated from an external data source. As the XML data is updated, you want to refresh the included data in your document.

To manually include the XML data in a document field, using the Word 2003 user interface:

  1. On the Insert menu, click Field.
  2. In the Field names list, select IncludeText.
  3. In the Filename or URL box, type the location of the target XML file, and click OK to include all of the XML data. To include only a portion of the XML data, continue with the steps 4 through 7.
  4. Specify namespace mappings by selecting the Namespace mappings check box and type the namespace mappings in the accompanying text box.
  5. If you want to transform the XML file's data before you include it in the document, select the XSL transform file check box and type the location of the target XSL transform file.
  6. Check the XPath expression check box and type an XPath expression, including namespaces if needed.
  7. Click OK to include the XML data.

For example, using the XML data in the previous example, assuming the file name is books_instance.xml and is in the same directory as the active Word document, the Field dialog box would be completed as follows:

  • **Filename or URL  **books_instance.xml
  • **Namespace mapping  **xmlns:ns1='schema.xsd'
  • **XPath expression  **/ns1:bookstore/ns1:book/ns1:author/ns1:last-name

The resulting field code looks like this:

{ INCLUDETEXT  "books_instance.xml" \c xml \n xmlns:ns1='schema.xsd' \x /ns1:bookstore/ns1:book/ns1:author/ns1:last-name  \* MERGEFORMAT }

And the field code's results look like this:

Cornell

Programmatically, you use the Fields collection's Add method to add an INCLUDETEXT field by specifying wdFieldIncludeText for the Type argument and providing the rest of the field's information in the Text argument. For example, the following code programmatically inserts the previous field code at the active document's insertion point:

...
ActiveDocument.Fields.Add Range:=Application.Selection.Range, _
    Type:=wdFieldIncludeText, _
    Text:="books_instance.xml " & _
        "\c xml \n xmlns:ns1='schema.xsd' " & _
        "\x /ns1:bookstore/ns1:book/ns1:author/ns1:last-name"

Excel 2003 also supports XML features such as displaying and accessing customer-defined XML (not just Excel flattened XML data and XML Spreadsheet formatted data as in Excel 2002). You can create a mapping between a customer-defined XML schema and an Excel workbook by adding the customer-defined XML schema to the accompanying workbook and then using the XML Source task pane to drag and drop schema elements onto the grid. That mapping persists with the workbook so that the next time you open up the workbook, you can import and export XML data through that mapping. To create a customer-defined XML file in Excel, on the Data menu, point to XML, click XML Source, and follow the directions in the XML Source task pane to map the customer-defined XML schema onto an Excel worksheet. See Figure 3 for a screen shot of the XML data design environment.

click for larger image

Figure 3. The Excel 2003 XML data design environment.

Programmatically, the XmlDataBinding, XmlMap, XmlNamespace, XmlSchema, and XPath objects, and the XmlMaps, XmlNamespaces, and XmlSchemas collections in Excel 2003 can enable your code to bind to XML data sources, map XML data structures to Excel worksheet data, map XML namespace prefixes to XML namespace declarations, reference XML schemas, return an XPath statement for a given piece of Excel data, and more.

Smart Documents

I've heard a lot of Office developers ask how they can create their own task panes, similar to task panes such as the New Document task pane, the Mail Merge task pane, and so on that were introduced in Office XP. In Office 2003 you can create customized task panes that interact with Word 2003 documents and templates and Excel 2003 workbooks and templates. An Office 2003 customized task pane along with a Word 2003 document or template or Excel 2003 workbook or template and any other solution-specific files is currently called a smart document (see Figure 4).

click for larger image

Figure 4. An Excel 2003 smart document

Smart documents are documents with an underlying XML structure that are programmed to know what users need to do with them and give users help along the way. As a user moves through a smart document, the location of their insertion point (Word) or active cell (Excel) determines what is displayed in the task pane. This empowers you as a developer to provide everything from context-sensitive guidance text to external data to calculation and query fields that may help the user work on that portion of the document. Depending on how a smart document solution is developed, the document may even know when the user is finished with it and be able to tell the user what to do next.

Here's how smart documents work from a solution development perspective:

  1. First, attach an XML schema to a Word 2003 document or Excel 2003 workbook and annotate the portions of the document that will have smart document actions or help content associated with them with XML.
  2. Save the Word 2003 document or Excel 2003 workbook as a template to make creating an instance of the template easier for your users from the New Document task pane.
  3. Write code using the ISmartDocument interface (or create an XML file that conforms to the smart document XML schema) to display actions and help content in the Document Actions task pane and handle those actions.
  4. Create a solution manifest that references the files that are used by the smart document. This manifest is placed in a location that's referred to by the smart document's custom document properties.
  5. Place the solution's files in the locations referred to in the solution manifest.

To use the smart document, users simply open the Word 2003 document or Excel 2003 workbook that is designed to be a smart document and start interacting with it. Not only do smart documents feature "no-touch" deployment, but security concerns are addressed as well:

  • Smart documents can be controlled by security policies.
  • Solution manifests must come from trusted sites. The solution manifests themselves must be code signed or otherwise trusted.
  • Code that runs as part of a smart document solution is subject to the users' Office security settings.
  • Users are prompted whether to initiate a smart document solution install.

Since smart document solutions can be loaded from a server, they can also be updated from the server, which simplifies the process of updating a solution.

Keep checking back with the Office Talk column and the MSDN Office Developer Center over the next several months as we demonstrate how to create and deploy smart document solutions in Word 2003 and Excel 2003.

"Visual Studio Tools for Office"

Not a month goes by where I don't hear several Office solution developers asking Microsoft in chats or newsgroups about when Visual Studio® .NET, Visual Basic .NET, Visual Studio for Applications (VSA), or something similar will be built into a version of Office. Office solution developers are beginning to express widespread interest in creating Office solutions based on Visual Basic .NET or Visual C# .NET and the Microsoft .NET Framework Class Libraries. We get closer to this goal in Office 2003 with a product code-named "Visual Studio Tools for Office."

With these new tools, Word 2003 documents and templates and Excel 2003 workbooks can be automated by Visual Basic .NET or Visual C# .NET code written in the next version of Visual Studio, Microsoft Visual Studio .NET 2003. Note that this is different than the Office XP Primary Interop Assemblies (PIAs). The Office XP PIAs allow Visual Studio .NET project code to externally automate Office XP; however, Office XP does not associate your customization with a specific Office document, template, or workbook. In contrast, "Visual Studio Tools for Office" allow Office 2003 developers to write managed code extensions in Visual Studio .NET 2003 that execute behind Word 2003 documents or templates and Excel 2003 workbooks. You get the full advantage of the Visual Studio .NET 2003 and .NET Framework environments, thereby allowing you to create .NET based solutions and migrate your existing Word 2003 and Excel 2003 solutions over to .NET, over time and as it makes sense to your business.

Office documents with these managed code extensions incorporate .NET security, which enables your solution to take advantage of a range of evidence on which to base trust decisions. The default policy does not permit any assembly to run, which protects users from viruses and other malicious code. Before end users can take advantage of a document's managed code extensions, the administrator must explicitly grant full trust to an assembly or location. For example, a universal naming convention (UNC) path to a corporate server could be granted full trust, allowing all clients to execute customizations hosted on that server.

Developers can take advantage of the project templates provided by "Visual Studio Tools for Office" to write document extensions in Visual Basic .NET or Visual C# .NET with Visual Studio .NET 2003, as shown in Figure 5, Figure 6, and Figure 7. The code that you write is stored separately from the document or workbook in an assembly so it can be easily updated when deployed on a server, but it is able to respond to events that occur in the document or workbook. By making changes in a centralized location, the changes can be consumed by every client that uses the solution.

Figure 5. The Visual Studio .NET 2003 New Project dialog box displaying Word 2003 and Excel 2003 Visual Basic project templates.

Figure 6. The Visual Studio .NET 2003 New Project dialog box displaying Word 2003 and Excel 2003 Visual C# project templates.

click for larger image

Figure 7. Sample code for the Excel 2003 Visual Basic project.

You gain many other benefits by using Visual Studio .NET 2003 and "Visual Studio Tools for Office" to create Office solutions, including:

  • Language improvements, such as strict type checking, structured exception handling, inheritance, and polymorphism.
  • Productivity tools, such as the Server Explorer, an integrated task list, Dynamic Help, and a visual XML designer.
  • Visual user interface design features, such as control anchoring and docking without writing code, as well as in-place menu editing.
  • Simplified and robust application deployment through auto-deployment, side-by-side deployment, and XCOPY deployment.
  • Connecting to your data, the Internet, and your customers' business logic through integrated XML Web services tools, using ADO.NET to provide XML-based data that spans applications and firewalls, and using managed data providers for seamless connections to OLE DB and ODBC data sources.

Stay tuned to the Office Talk column and the MSDN Office Developer Center in the coming months for complete coverage of how to use "Visual Studio Tools for Office."

Smart Tag Enhancements

Smart tags provide many enhancements for Office 2003, including:

  • Enhancements to MOSTL (the smart tag recognizer and action handler run time that can be extended by building XML files rather than writing code) include support for regular expressions and context free grammar-based recognition, as well as support for setting properties on items in a list of terms.
  • Smart tag actions can be run automatically when a recognizer labels a string as a smart tag, not just when a user clicks a choice on a smart tag action menu.
  • The name of an action can depend on the string that's been tagged, and a particular smart tag action can even be hidden if it isn't appropriate for your solution.
  • You can build smart tag actions that are associated with XML elements in Word and Excel documents exactly the same way you build them for smart tags that work with strings.
  • Smart tag action menus can have cascading submenus.
  • Streams of tokens can be passed in to smart tag recognizers in addition to raw text. This will make developing smart tag recognizers for East Asian languages that don't have spaces between words much easier and will simplify development for Western languages as well because developers can operate on tokens rather than having to worry about separating a text buffer into words based on white space and punctuation cues.
  • Smart tag recognizers and actions can be reloaded without restarting Office applications.
  • Smart tags can be deployed for all users on a computer, not just the user who installed them.
  • Enable/disable buttons and underlining are available for individual smart tags.

Smart tags are new for the next version of Microsoft PowerPoint® (code-named PowerPoint 2003) and the next version of Microsoft Access (code-named Access 2003), as well as enhanced for Word 2003, Excel 2003, and the next version of Microsoft Outlook® (code-named Outlook 2003) when reading HTML e-mail and writing e-mail with Word 2003 as your e-mail editor.

Figure 8 shows an Access 2003 smart tag in action.

click for larger image

Figure 8. An Access 2003 smart tag.

The SmartTag, SmartTagAction, and SmartTagProperty objects and the SmartTags, SmartTagActions, and SmartTagProperties collections can be used to add, delete, and return information about available smart tags in Access 2003. For example:

Public Sub SmartTagInfo()

    ' Purpose: Displays information about any smart tags
    ' attached to an Access 2003 form control.
    
    Dim objMailingListForm As Access.Form
    Dim objMailingListIDTextBox As Access.TextBox
    Dim objSmartTag As Access.SmartTag
    Dim objSmartTagAction As Access.SmartTagAction
    Dim objSmartTagProperty As Access.SmartTagProperty
    Dim strMsg As String
    
    ' Assume you have a form named "Mailing List" with
    ' a text box named "MailingListID" and the text box
    ' has one or more associated smart tags
    ' (control's Properties window, All tab, Smart Tags list
    ' to select / display smart tags for the control).
    
    Application.DoCmd.OpenForm FormName:="Mailing List"
    
    Set objMailingListForm = Application.Forms![Mailing List]
    Set objMailingListIDTextBox = _
        objMailingListForm.Controls.Item(Index:="MailingListID")
    
    For Each objSmartTag In objMailingListIDTextBox.SmartTags
    
        strMsg = objMailingListIDTextBox.Name & " has a smart tag named _
            " & objSmartTag.Name & " with these actions: " & vbCrLf
            
        For Each objSmartTagAction In objSmartTag.SmartTagActions
        
            strMsg = strMsg & objSmartTagAction.Name & vbCrLf
            
        Next objSmartTagAction
    
    Next objSmartTag
        
    MsgBox strMsg
End Sub

Figure 9 displays how to associate a smart tag with an Access 2003 form control at design time.

click for larger image

Figure 9. Associating a smart tag with an Access 2003 form control.

List Technology

In Office 2003 terms, a list typically refers to a collection of information in a Web site based on SharePoint™ Team Services from Microsoft. A list is typically a set of records that are shared among the Web site's members. For example, you can create a list of events, a list of ideas, a list of members' contact information, and so on.

You can use the various Office 2003 products to connect to, import, export, and modify data in lists; for example:

  • Access 2003 can import lists, export lists, and link to lists.
  • Excel 2003 can import lists and publish lists.
  • You can use the next version of Microsoft FrontPage® (code-named FrontPage 2003) to modify Web sites based on SharePoint Team Services just as with FrontPage 2002.
  • Outlook 2003 can connect to and modify lists based on the Announcements and Contacts list types.

Let's look briefly at how lists are implemented in Excel 2003. Lists become first-class programmatic citizens in Excel 2003 on a par with standard worksheet cell ranges (see Figure 10).

Figure 10. An Excel 2003 data list.

To create a list in Excel, on the Data menu, point to List and click Create List. After you finish creating the list, you can publish it to a Web site based on SharePoint Team Services by pointing to List on the Data menu and clicking Publish.

Programmatically, the ListColumn, ListDataObject, ListFormat, ListObject, and ListRow objects, and the ListColumns, ListObjects, and ListRows collections can be used to create, modify, and navigate data lists in Excel 2003. For example:

Public Sub InsertDataList()

    ' Purpose: Inserts a data list into the active
    ' Excel 2003 worksheet, starting at cell A1.

    Dim objWks As Excel.Worksheet
    Dim objList As Excel.ListObject
    Dim objColumn As Excel.ListColumn
    Dim objRange As Excel.Range
    
    Set objWks = Excel.Application.ActiveSheet
    Set objList = objWks.ListObjects.Add(SourceType:=xlSrcRange, _
        Source:=objWks.Range(Cell1:="A1"), HasHeaders:=True)
        
    With objList
        
        .Range(RowIndex:=1, ColumnIndex:=1).Value = "First Name"
        .Range(RowIndex:=1, ColumnIndex:=2).Value = "Last Name"
        .Range(RowIndex:=1, ColumnIndex:=3).Value = "Organization"
        .Range(RowIndex:=2, ColumnIndex:=1).Value = "Paul"
        .Range(RowIndex:=2, ColumnIndex:=2).Value = "Cornell"
        .Range(RowIndex:=2, ColumnIndex:=3).Value = "Microsoft"
    
        ' Value is "Last Name".
        MsgBox "The value of column cell 2, row cell 1 is " & _
            .ListColumns(Index:=2).Range(RowIndex:=1).Value & "."
            
        ' Value is "Cornell" (ignores the header row).
        MsgBox "The value of row cell 2, column cell 2 is " & _
            .ListRows(Index:=1).Range(RowIndex:=2).Value & "."
                
    End With
    
End Sub

Other Primary Office 2003 Object Model Additions

Many of the new Office 2003 application features can be automated and extended through the Office 2003 object models. While a complete technical discussion of all of the Office 2003 object model additions is outside the scope of this month's column, following are briefly some of the other primary Office 2003 object model additions besides what has already been mentioned to whet your developer appetite.

Access 2003

The AutoCorrect object is used to display the new Access 2003 AutoCorrect Options smart tag, which allows users to allow automatic correction of things like misspellings, similar to Word 2002 and Excel 2002 (see Figure 11).

Figure 11. The Access 2003 AutoCorrect Options smart tag.

The new Access 2003 AutoCorrect object contains one property, DisplayAutoCorrectOptions, which when set to True or False turns the AutoCorrect Options smart tag on or off.

The DependencyInfo object allows programmatic access to the information displayed in the Access 2003 Object Dependencies task pane, which displays whether a selected Access 2003 object (for example, a data table) has any other objects depending on it or whether it depends on any other objects itself (see Figure 12).

click for larger image

Figure 12. The Access 2003 Object Dependencies task pane.

The DependencyInfo object allows you to gain programmatic access to a collection of AccessObject objects representing specific object dependencies, as follows:

Public Sub DisplayDependenciesForQuery()

    ' Purpose: Programmatically display what you would get if you
    ' displayed the Access 2003 Object Dependencies task pane for 
    ' a selected query object.

    Dim objMailingListQuery As Access.AccessObject
    Dim objAccessObject As Access.AccessObject
    Dim objDependencyInfo As Access.DependencyInfo
    
    ' Assume you have a query named "Mailing List Query" 
    ' that depends on a table named "Mailing List".
    Set objMailingListQuery = _
        Application.CurrentData.AllQueries.Item _
        (var:="Mailing List Query")
    
    If objMailingListQuery.GetDependencyInfo.Dependencies.Count = 0 Then
    
        MsgBox objMailingListQuery.Name & " has no dependencies."
    
    Else
    
        For Each objAccessObject In _
                objMailingListQuery.GetDependencyInfo.Dependencies
            
            ' Displays "Mailing List Query depends on Mailing List."
            MsgBox objMailingListQuery.Name & " depends on " & _
                objAccessObject.Name & "."
                
        Next objAccessObject
        
    End If
    
End Sub

Office 2003 Shared Features

Document workspaces in Excel 2003, PowerPoint 2003, and Word 2003 allow users to add documents to or delete documents from shared workspaces based on SharePoint Team Services from Microsoft to manipulate workspace data such as people, tasks, links, and related files (see Figure 13 below). The SharedWorkspace, SharedWorkspaceFile, SharedWorkspaceFolder, SharedWorkspaceLink, SharedWorkspaceMember, SharedWorkspaceTask object, and the SharedWorkspaceFiles, SharedWorkspaceFolders, SharedWorkspaceLinks, SharedWorkspaceMembers, and SharedWorkspaceTasks collections can be used to programmatically automate document workspaces.

click for larger image

Figure 13. The Word 2003 Shared Workspace task pane.

The Sync objects in Word 2003, Excel 2003, and PowerPoint 2003 are used to electronically upload, download, and maintain copies of documents, workbooks, and presentations both on the local computer and document workspaces. The Sync objects duplicate the user interface functionality of the Document Updates task pane as follows:

Public Sub SyncStatus()

    ' Purpose: Determines whether the active Word 2003 document
    ' relies on a shared workspace.
    
    Dim objDoc As Word.Document
    
    Set objDoc = Application.ActiveDocument
    
    If objDoc.Sync.Status = msoSyncStatusNoSharedWorkspace Then
        
        MsgBox "This document is not stored in a shared workspace."
        
    Else
    
        MsgBox "This document is stored in a shared workspace."
        
    End If
        
End Sub

The SmartDocument object is used to access Word 2003 and Excel 2003 smart documents. See the Smart Documents section above for more information on smart documents.

Outlook 2003

The Conflict object and Conflicts collection are used to get information about Outlook 2003 item conflicts. For example, let's say you take Outlook 2003 offline on a laptop on an airplane and you send a meeting request to someone. Back at your office, while the laptop is still offline, using a desktop computer you go online with Outlook 2003 and create and send an identical meeting request. When you use your laptop to go online with Outlook 2003 later, the original meeting request item appears in your Outlook Conflicts folder. You can programmatically check for and report on conflicts with the Outlook 2003 object model.

Word 2003

To allow greater control over document and drawing positioning and layout, Word 2003 provides the Break, Line, Page, and Rectangle objects and the Breaks, Lines, Pages, and Rectangles collections.

The Editor object and Editors collection represent user-editing permissions on a given Range or Selection object and programmatically mimics the Protect Document task pane's user interface. Here's a code sample:

Public Sub EditorInfo()

    ' Purpose: Displays who can edit the active
    ' document's selected text.

    Dim objSelection As Word.Selection
    Dim objEditor As Word.Editor
    Dim intEditor As Integer
    
    Set objSelection = Application.Selection
    
    If objSelection.Editors.Count > 0 Then
        
        For intEditor = 1 To objSelection.Editors.Count
        
            MsgBox objSelection.Editors.Item(Index:=intEditor).Name & _
                " can edit this selection."
                
        Next intEditor
            
    Else
    
        MsgBox "There are no editors defined for this selection."
        
    End If
        
End Sub

Bookmark the Office Talk column and the MSDN Office Developer Center, and keep revisiting these Web sites over the next several months as we provide code samples of how to use the new Office 2003 object models.

Microsoft "XDocs"

A new Office 2003 family application, code named Microsoft "XDocs," provides an intuitive, graphical user interface for filling out, reviewing, signing, and submitting rich, dynamic business forms in a flexible, XML-based format, without exposing the inner workings of XML to your end users. "XDocs" form developers can write code to process the submitted XML data behind the online business forms according to a business's needs. "XDocs" form developers can modify the sample "XDocs" business forms out of the box to fit their unique business needs, create and design new "XDocs" forms for end users, and modify existing "XDocs" XML Schemas for advanced form template creation and customization, in many cases using the "XDocs" graphical design environment. See Figure 14 and Figure 15 for an "XDocs" sample form being filled out and designed.

click for larger image

Figure 14. The "XDocs" Absence Request sample form being filled out.

click for larger image

Figure 15. The "XDocs" Absence Request sample form being designed.

"XDocs" form developers can programmatically automate and extend "XDocs" forms through Web scripting code, authored in Microsoft Visual Basic Scripting Edition (VBScript) or Microsoft JScript®, using the Microsoft Script Editor (see Figure 16).

click for larger image

Figure 16. Sample "XDocs" Web scripting code displayed in the Microsoft Script Editor, included with "XDocs".

"XDocs" business forms are actually a collection of XML data files, XML Schema files, XSL Transformation files, and Web scripting files. An "XDocs" form template includes a form definition file, which is a manifest of all of the component files that make up an "XDocs" form template file.

In the coming months, we'll provide lots of technical articles and code samples on "XDocs" form development. Stay tuned!

Built-In XML Web Services Support

You can use the Office XP Web Services Toolkit 2.0 to integrate XML Web services into your Office XP solutions. The Toolkit will be revised for Office 2003 and be released to the Web as an Office 2003 add-on. To integrate XML Web services into your Office 2003 solutions, in the Office 2003 Visual Basic Editor, on the Tools menu, click Web Service References, provide the information requested by the Web Service References dialog box, and write code to automate the referenced XML Web service. The Web Service References Tool in turn automatically references the Microsoft Office Soap Type Library v3.0 and the Microsoft XML, v5.0 type library to enable programmatic SOAP support and XML parser support in your XML Web service-enabled VBA projects.

Office 2003 Primary Interop Assemblies

You can use the Office XP Primary Interop Assemblies (PIAs) to automate or extend Office XP from Visual Studio .NET projects. The PIAs will be updated for Office 2003 to allow Visual Studio .NET project code to automate and extend Office 2003 features. Even better, "Visual Studio Tools for Office" allows you to automate and extend the Word 2003 and Excel 2003 object models and the .NET Framework Class Libraries using Visual Basic .NET or Visual C# .NET code in conjunction with Visual Studio .NET 2003. See the "Visual Studio Tools for Office" section for more details.

When to Use VBA, Smart Documents, "Visual Studio Tools for Office," and Other Office 2003 Solution Options

With all of these current and new coding options available to Office developers in the near future, one big question remains—which option should you choose for a particular Office 2003 solution project?

  • You should continue to use VBA when your solution requires code to live in, and travel attached to, a document; or your solution involves simple macros (or recorded macros) that directly access the built-in Office COM-based object models.
  • You should continue to use application specific add-ins when you want to create application-specific template code that applies, for instance, to just Excel, and you feel that COM technologies and COM-based type libraries meet your solution needs.
  • You should continue to use Office COM add-ins when you want to: create a combination of generic and application-specific code across several Office applications, manage individual desktop deployment issues such as versioning, code an add-in for an Office application other than Word 2003 or Excel 2003, or feel comfortable using COM for your solution needs.
  • You should consider using Office managed add-ins when you want to create an Office add-in using the power of Visual Studio .NET and the .NET Framework along with the Office 2003 primary interop assemblies.
  • Smart tags should be considered when you want to execute context-sensitive actions in Word 2003 documents, Excel 2003 workbooks, Outlook 2003 items, PowerPoint 2003 presentations, or Access 2003 databases. They are also useful for tagging data with meaningful types that are important to your business for later searching and reuse.
  • Smart documents are a great choice for Word 2003 XML-based documents and Excel 2003 XML-based workbooks when you want to allow a customized task pane to interact with both the Office file and the user to enhance solutions' capabilities. They also provide a simplified and more secure deployment model than COM add-ins.
  • You should consider using Microsoft "XDocs" when you want to have users fill out structured business forms and integrate the business forms' underlying XML data into business processes.
  • Finally, "Visual Studio Tools for Office" is an ideal candidate for Word 2003 documents and templates and Excel 2003 documents when you want Office to harness the power of Visual Studio .NET 2003, the .NET Framework version 1.1, and the Office 2003 primary interop assemblies by directly calling remotely-updateable Visual Basic .NET or Visual C# .NET code instead of VBA code.

You should begin thinking about your existing and upcoming Office solution projects in terms of these proposed Office 2003 features. What Office 2003 proposed feature enhancements will you be able to add to your Office 2003 solutions? XML enhancements, smart tags, smart documents, document workspaces, .NET Framework Class Library support, or other features? The list of feature enhancements will undoubtedly grow and get more refined as Office 2003 gets closer to the final public release.

Be sure to watch this column for upcoming information about how to participate in Office 2003 Beta 2.

**Note   **We have added a lot of technical content on Office 2003 developer-oriented features at https://msdn.microsoft.com/office/. Visit this page often for additional updates.

Paul Cornell works for the MSDN Online Office Developer Center and the Office developer documentation team. Paul also contributes to the Office Power User Corner column for the Office Assistance Center. He spends his free time with his wife and two daughters.