【发布时间】:2023-01-18 04:15:17
【问题描述】:
我正在编写代码以从下拉列表中选择特定的自动文本。自从 1970 年代后期旧的 Basic A 以来,我就没有写过代码……我已经忘记了大部分。
下拉列表称为 HVAC
要插入的文本位于名为“Split Systems”的自动文本文件中或与下拉项关联的任何文本中
错误信息是“5941 请求的集合成员不存在”
我试过在 if 语句行中使用 1、2、3 或 4 的值而不是“Split...”,它也不起作用
问题在哪里或我应该如何编码。
我的代码如下:
Sub one()
If ActiveDocument.Formfields(hvac).DropDown.Value = "Split Systems" Then GoTo 10 Else GoTo 20
10
ActiveDocument.Content.Select
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.AttachedTemplate.AutoTextEntries("Split Systems").Insert _
Where:=Selection.Range, RichText:=True
GoTo 100
20
If ActiveDocument.Formfields(hvac).DropDown.Value = "Packaged Systems" Then GoTo 25 Else GoTo 30
25
ActiveDocument.Content.Select
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.AttachedTemplate.AutoTextEntries("Packaged System").Insert _
Where:=Selection.Range, RichText:=True
GOto 100
30
If ActiveDocument.Formfields(hvac).DropDown.Value = Central Heating System" Then GoTo 35 Else GoTo 40
35
ActiveDocument.Content.Select
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.AttachedTemplate.AutoTextEntries("Central Heating System").Insert _
Where:=Selection.Range, RichText:=True
GoTo 100
40
If ActiveDocument.Formfields(hvac).DropDown.Value = "PTACs" Then GoTo 45
45
ActiveDocument.Content.Select
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.AttachedTemplate.AutoTextEntries("Central Heating System").Insert _
Where:=Selection.Range, RichText:=True
100
End Sub
尝试了我所知道的一切
【问题讨论】: