I am writing a form in Word 2003 to collect multiple responses to a single question. I have a macro on a button press which duplicates the various input fields (drop-down boxes, radio buttons etc.) ready for a new response.
However, I need to change the text of the radio buttons, and set the OnChange
event on a combobox, and I can't find the correct syntax to do so. Both the controls are from the 'Control Toolbox' toolbar.
The macro code I have to duplicate the controls is below.
Private Sub CommandButton11_Click()
Set Doc = ActiveDocument
Response = MsgBox("Add another response?", vbYesNo, "Confirm action")
If Response = vbYes Then
If Doc.ProtectionType <> wdNoProtection Then
Doc.Unprotect
End If
Selection.MoveRight
Selection.MoveDown
Selection.TypeParagraph
''# keep the reference to this control and set the OnChange event handler
Selection.InlineShapes.AddOLEControl ClassType:="Forms.ComboBox.1"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=vbTab
Selection.TypeText Text:=vbTab
''# keep the reference to this control and set text
Selection.InlineShapes.AddOLEControl ClassType:="Forms.OptionButton.1"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Doc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
End Sub