Microsoft Office Professional Developer Portal
 Print Print
Average Rating: 4.8/5 | Rate this item | 5 users have rated this item.
Designing Smart Documents in Office 2003 (cont'd)
Writing SmartDocument Managed Code
Just like you implemented ISmartDocument interface definitions in the VB6 Shim, implement the ISmartDocument interface in a new .NET class library project (the sample code uses VB.NET). Rename the project to "CustomerManagement" and the default class to "Customer.vb." In most cases, VB.NET is a better choice for Office 2003 programming, because of its similarity to VBA, which is the native language for Office-based applications.


Table 1 and Table 2 contain some important interface methods that you may need to implement. I've separated these into two sections, even though the interface documentation contains no such differentiation.

Table 1. SmartNodeInitalizers: Interface implementations that concern document and XmlType initialization.
Method Description
SmartDocInitialize As the name suggests, this is the document initializer. Any startup tasks should go in this method, which is executed once during the document initialization phase.
SmartDocXmlTypeCount You return the number of Smart Nodes (XMLTypes) that will be hooked up to the Document actions pane. Note: I've termed XmlTypes as Smart Nodes because they are intelligent nodes of the document. Each such node brings in a portion of the total functionality of an intelligent document.
SmartDocXmlTypeName You will return the XMLTypeName—the name of the node for a given XmlTypeID.
SmartDocXmlTypeCaption Specifies the caption in the document actions pane for a given XmlTypeID.

Table 2. Control handlers: These methods act as successors to the methods shown in Table 1, and control the content rendered in the Document actions pane for an associated smartNode or Xml Type.
Method Description
ControlCount Returns the number of controls associated with a specific XmlType.
ControlNameFromID Declares a name for the control with a given ControlID. You can later use this to actually get access to the controls.
ControlTypeFromID For a given ControlID you could say which control to render using a C_TYPE enum, for example, C_TYPE.C_TYPE_COMBO, C_TYPE.C_TYPE_BUTTON, C_TYPE.C_TYPE_ACTIVEX, etc.
OnPaneUpdateComplete This is a finalize phase where you code for actions, after all the controls, etc are rendered/populated as required in the Document task pane.
ControlCaptionFromID Retrieve a caption for the specified control
PopulateListOrComboContent Whenever you specify a LISTBOX or COMBO in your task pane via the ControlTypeFromID method, this method is automatically hooked up and fires so you can populate the list.
InvokeControl This method fires when a user clicks a button, hyperlink, etc
OnListOrComboSelectChange This event occurs after any selection change for a ListBox or ComboBox.

Tables 1 and 2 are by no means comprehensive, but you can find a complete list here.

Now that you've seen the basic components involved in putting together a SmartDocument, you can begin working on the implementation phase.

Previous Page: Applying Schema Next Page: Initializing the Document


Page 1: IntroductionPage 7: Implementing Control Definitions
Page 2: Getting StartedPage 8: Rendering and Populating Controls
Page 3: Applying SchemaPage 9: Populating ComboBoxes in the Itemname and Region Nodes
Page 4: Writing SmartDocument Managed CodePage 10: Reading Values from SmartDocuments
Page 5: Initializing the DocumentPage 11: Creating a Manifest
Page 6: Implementing XMLType Definitions