Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Previous Adding Radio Buttons
The following steps show you how to add a check box to the SimpleSample smart document.
The first thing you need to do is add a constant for the checkbox element in the SimpleSample schema. Insert the following code into the general declarations section of your code module, below the existing constants.
Const cCHECKBOX As String = cNAMESPACE & "#checkbox"Next you need to add 1 to the cTYPES constant. Remove the existing cTYPES constant, and enter the following code or change your code to match.
Const cTYPES As Integer = 6Now you are ready to modify the existing code to insert the check boxes. The subroutines you need to modify are SmartDocXMLTypeName, SmartDocXMLTypeCaption, ControlCount, ControlID, ControlTypeFromID, and ControlCaptionFromID.
In the SmartDocXMLTypeName property, insert the following code.
Case 6 SmartDocXmlTypeName = cCHECKBOXIn the SmartDocXMLTypeCaption property, insert the following code.
Case 6 SmartDocXmlTypeCaption = "Checkboxes"In the ControlCount property, insert the following code.
Case cCHECKBOX ControlCount = 2In the ControlID property, insert the following code.
Case cCHECKBOX ControlID = ControlIndex + 500In the ControlTypeFromID property, insert the following code. You are adding two check boxes to the SimpleSample smart document, so you need to add two check box controls.
Case 501, 502 ControlTypeFromID = C_TYPE.C_TYPE_CHECKBOXIn the ControlCaptionFromID property, insert the following code. Again, you are adding two check boxes, so you need two captions.
Case 501 ControlCaptionFromID = _ "Show/Hide paragraph marks." Case 502 ControlCaptionFromID = _ "Show/Hide XML tags."The PopulateCheckbox method specifies the initial state of the check boxes. For the two check boxes in the SimpleSample smart document, the initial state is checked, as shown in the following code.
Select Case ControlID Case 501, 502 Checked = True End SelectThe OnCheckboxChange method specifies what happens when a user clicks a check box. In the SimpleSample smart document, when the user selects or clears one of the check boxes, a Microsoft Word option is turned on or off.
Dim objDoc As Microsoft.Office.Interop.Word.Document Dim objView As Microsoft.Office.Interop.Word.View objDoc = Target.Document objView = objDoc.ActiveWindow.View Select Case ControlID Case 501 objView.ShowAll = Not objView.ShowAll Case 502 objView.ShowXMLMarkup = Not objView.ShowXMLMarkup End SelectRecompile 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.