Today, most organizations have a wealth of Office documents that contain critical information, but finding, extracting, and reusing that information programmatically remains a largely unrealized goal. Fortunately, that's changing as XML processing in Microsoft Office 2003 grows up.
by Vishnu Prasad
Oct 20, 2004
Page 4 of 11
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.
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.
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.
You will return the XMLTypeNamethe name of the node for a given XmlTypeID.
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.
Returns the number of controls associated with a specific XmlType.
Declares a name for the control with a given ControlID. You can later use this to actually get access to the controls.
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,
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.
Retrieve a caption for the specified control
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.
This method fires when a user clicks a button, hyperlink, etc
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.