我正在编写一个Word 2003表单,用于收集对同一问题的多个回答。我有一个按钮宏,按下后会复制各种输入字段(下拉框、单选按钮等),以准备接受新的回答。
然而,我需要更改单选按钮的文本,并在组合框上设置OnChange事件,但我无法找到正确的语法进行操作。这两个控件都来自“控件工具箱”工具栏。
下面是我用于复制控件的宏代码。
然而,我需要更改单选按钮的文本,并在组合框上设置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
Application.OnTime VBA.Now + 0.000001, "prcCreateReference"
,只有稍微不到1/10秒。哦,我正在使用Word 2007。 - Hannah Vernon