Share via


Step 3: Creating the SimpleSample DLL (Visual Basic .NET Tutorial) [Office 2003 SDK Documentation]

Previous   Step 2: Setting Up Your Visual Basic .NET Project

The smart document dynamic-link library (DLL) contains the actions and logic for the smart document. The following procedure shows you how to create a smart document DLL by using Microsoft Visual Basic .NET.

  1. In the clsActions class module, insert the code that implements the ISmartDocument interface.

    Important   If you copied the entire code from the SimpleSample smart document code module, you can go to step 6. However, you might want to read through to step 6 to understand what each of the subroutines does.

  2. Insert the code for the smart document constants.

  3. Insert the SmartDocInitialize method. (There is no code to insert into this method.)

    Note  To insert the SmartDocInitialize method into your code, select ISmartDocument from the Object list. (The Class Name list is the drop-down list to the top left of the code view.  Click the down arrow and select ISmartDocument from the list.  Then select the SmartDocInitialize method from the Method Name drop-down to the top right of the code view.)

  4. Define the number of types (or elements) that will have controls and actions assigned to them. For the SimpleSample smart document, there is one type, cTEXTBOX.

    • Insert the code for the SmartDocXmlTypeCount property to specify the number of elements that will have controls and actions assigned to them.

      Note  To insert the SmartDocXmlTypeCount property into your code module, select SmartDocXmlTypeCount from the Procedures list (the drop-down list to the top right of the code view). You can use this procedure to insert any of the other properties and methods in the ISmartDocument interface into your code module.

    • Insert the code for the SmartDocXmlTypeName property to assign names to the element constants that you specified earlier.

    • Insert the code for the SmartDocXmlTypeCaption property to specify the caption that will be displayed in the Document Actions task pane for the type.

  5. Define the number of controls for each of the types specified earlier. Each type can have one or more controls associated with it, and each of those controls can be any of the controls specified in the c_TYPE constants. 

    • Insert the code for the ControlCount property to specify the number of controls that you want to create for each of the types specified earlier.

    • Insert the code for the ControlID property to provide a unique identifier for each of the controls in the smart document.

    • Insert the code for the ControlNameFromID property to specify a friendly name that you can use to access each of your controls from the application's Visual Basic for Applications (VBA) object model.

    • Insert the code for the ControlCaptionFromID property to specify the caption displayed in the Document Actions task pane for each of the controls.

    • Insert the code for the ControlTypeFromID property to specify the type of control.

    • Insert the code for the PopulateTextboxContent method to specify what happens when the control is displayed.

      Note  This subroutine is empty because you are not specifying any actions for the text box when it is initially displayed in the Document Actions task pane. However, by using the PopulateTextboxContent method, you could initially populate a text box with data from a database or another source.

    • Insert the code for the OnTextboxContentChange method to specify what happens when the contents of the text box control changes.

      Note  You need to add a reference to the System.Windows.Forms namespace; otherwise, this code generates an error.

  6. Now you have added all the code that is necessary for the first part of the Simple Sample smart document. However, the ISmart Document interface requires that all methods and properties be present, regardless of whether they contain code. Therefore, add blank subroutines for the remaining methods and properties. 

    Note  You can determine which procedures are unused by opening the Procedure drop-down list, to the top right of the code view, and selecting each of the items that is not bold.

  7. Modify and run the SetPolicy.bat file.

    Note  If Microsoft Office Word 2003 is running when you run the SetPolicy.bat file, you must restart Word before opening the SimpleSample smart document.

Next   Step 4: Compiling the SimpleSample DLL