【发布时间】:2015-03-06 00:21:37
【问题描述】:
我是 VBA 新手,我找不到解决问题的方法。我使用带有下拉菜单的 Word 表单。此下拉菜单中的选项是名称。当我在下拉菜单中选择名称时,我希望 Word 自动填写 3 个其他(常规)表单域(带有联系方式)。基本上,我想要这里解释的内容(见链接),但不使用 Microsoft Access:
【问题讨论】:
我是 VBA 新手,我找不到解决问题的方法。我使用带有下拉菜单的 Word 表单。此下拉菜单中的选项是名称。当我在下拉菜单中选择名称时,我希望 Word 自动填写 3 个其他(常规)表单域(带有联系方式)。基本上,我想要这里解释的内容(见链接),但不使用 Microsoft Access:
【问题讨论】:
在学习 VBA 2 周后,解决方案似乎很简单。如果有人需要完成同样的事情,这就是它。随意使用!
If ActiveDocument.*name of dropdown field* = "contact person 1" Then
ActiveDocument.FormFields("formfield1").Result = "xxx"
ActiveDocument.FormFields("formfield2").Result = "xxx"
ActiveDocument.FormFields("formfield3").Result = "xxx"
ElseIf ActiveDocument.*name of dropdown field* = "contact person 2" Then
ActiveDocument.FormFields("formfield1").Result = "xxx"
ActiveDocument.FormFields("formfield2").Result = "xxx"
ActiveDocument.FormFields("formfield3").Result = "xxx"
ElseIf ActiveDocument.*name of dropdown field* = "contact person 3" Then
...etc
End If
【讨论】: