Я пишу форму в Word 2003, чтобы собрать несколько ответов на один вопрос. У меня есть макрос при нажатии кнопки, который дублирует различные поля ввода (раскрывающиеся списки, переключатели и т. Д.), Готовые для нового ответа.
Однако мне нужно изменить текст переключателей и установить событие OnChange
в поле со списком, и я не могу найти для этого правильный синтаксис. Оба элемента управления находятся на панели инструментов «Панель инструментов управления».
Код макроса, который я должен продублировать для элементов управления, приведен ниже.
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