Adding Help Content (Visual Basic 6.0 Tutorial) [Office 2003 SDK Documentation]
Previous Adding Command Buttons
The following steps show you how to add Help content to the SimpleSample smart document. In this section, you add two portions of Help text to the SimpleSample smart document. The first portion displays the Help globally for all elements and is attached to the top-level example element. The second portion displays Help text for the help element.
The first thing you need to do is add a constant for the <example> and help elements in the SimpleSample schema. Insert the following code into the general declarations section of your code module, below the existing constants.
Const cEXAMPLE As String = cNAMESPACE & "#example" Const cHELP As String = cNAMESPACE & "#help"
Next, you need to add 2 to the cTYPES constant. Remove the existing cTYPES constant, and enter the following code or change your code to match.
Const cTYPES As Integer = 4
You also need to add a path constant that contains the path of your smart document solution. In the case of the SimpleSample smart document, the path is stored to a local computer. However, you can also host it on a Web server or store it in a shared network location. Insert the following code into the general declarations section of your code module. You specify the path to use in the SmartDocInitialize subroutine.
Private strPath As String
To get a pointer to the location of the Help files, you need to specify the folder. However, because you might not know where the files are on a user's local computer, you use a relative path based on the path in the smart document's Document object. Insert the following code in the SmartDocInitialize subroutine that you added earlier.
strPath = Document.Path & "\"
Now you are ready to modify the existing code to insert the Help text. The subroutines you need to modify are SmartDocXMLTypeName, SmartDocXMLTypeCaption, ControlCount, ControlID, ControlTypeFromID, and ControlCaptionFromID.
In the SmartDocXMLTypeName property, insert the following code.
Case 3 ISmartDocument_SmartDocXmlTypeName = cEXAMPLE Case 4 ISmartDocument_SmartDocXmlTypeName = cHELP
In the SmartDocXMLTypeCaption property, insert the following code.
Case 3 ISmartDocument_SmartDocXmlTypeCaption = "Global Help text" Case 4 ISmartDocument_SmartDocXmlTypeCaption = "Help text"
In the ControlCount property, insert the following code.
Case cEXAMPLE ISmartDocument_ControlCount = 1 Case cHELP ISmartDocument_ControlCount = 1
In the ControlID property, insert the following code.
Case cEXAMPLE ISmartDocument_ControlID = ControlIndex + 200 Case cHELP ISmartDocument_ControlID = ControlIndex + 300
In the ControlTypeFromID property, insert the following code. When you specify the control type, use C_TYPE_HELP to specify Help content that is in the code and is passed as a string; use C_TYPE_HELPURL to specify Help content that is pulled from an external file and is passed as a file path. Help content, whether contained in the code or in an external file, should be well-formed HTML, or XHTML.
Case 201 ISmartDocument_ControlTypeFromID = C_TYPE_HELP Case 301 ISmartDocument_ControlTypeFromID = C_TYPE_HELPURL
In ControlCaptionFromID, insert the following code.
Case 201 ISmartDocument_ControlCaptionFromID = _ "Help text applies to all elements." Case 301 ISmartDocument_ControlCaptionFromID = _ "Help text applies only to the help element."
Add the code to populate the Help text. Use the PopulateHelpContent method to specify Help content. As noted earlier, one of the Help portions is specified by using C_TYPE_HELP and the other is C_TYPE_HELPURL. Insert the following code into the PopulateHelpContent method subroutine.
Select Case ControlID Case 201 Content = "<html><body><p>This is the SimpleSample " & _ "Smart Document.</p></body></html>" Case 301 Content = strPath & "help.htm" End Select
Note Not all HTML elements are supported for Help content displayed in the Document Actions task pane. For information about the elements that are supported, see Formatting HTML Help Content.
Recompile your SimpleSample smart document DLL, and copy it to the deployment location that you specified earlier. When you reopen your SimpleSample smart document, delete the SimpleSample XML expansion pack, and then re-add it to the document.
Next Adding Radio Buttons