【发布时间】:2010-09-23 18:32:52
【问题描述】:
我正在 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
【问题讨论】: