Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

Office 2003

Previous   Step 2: Set Up Your Visual Basic 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 6.0.

  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 jump ahead to step 6. However, you may want to read through 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 Object list is the drop-down list on the left above the code view. Click the down arrow and select ISmartDocument from the list. Because the SmartDocInitialize method doesn't already exist, Visual Basic automatically adds it to the code module.)

  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 or any of the other properties and methods in the ISmartDocument interface into your code module, select SmartDocXmlTypeCount from the Procedures list (the drop-down list on the right above the code view).

    • Insert the code for the SmartDocXmlTypeName property to assign names to the element constants that you specified above.
    • 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 above. 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 above.
    • 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.
  6. Now you have added all the code that is necessary for the first part of the SimpleSample 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 item that is not bold. (Items that are not bold are the unused procedures in the interface.)

Next  Step 4: Compile the SimpleSample DLL



Show: