如何在ms字中自动填充下拉内容控件? [英] How to auto populate drop down content control in ms word?

查看:79
本文介绍了如何在ms字中自动填充下拉内容控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我正在尝试根据用户在下拉列表中所做的选择来获得我的纯文本控件的值。我正在使用内容控制。谢谢你的帮助。

解决方案

你好Ej Ochoa,


我没有找到这样的事件做这个。
Document_ContentControlBeforeContentUpdate
可以捕获下拉列表中的更改,但由于所有内容控件共享同一事件,如果要在此事件中设置内容控件的值,则会出现错误。我建议您使用

Document_ContentControlOnExit
解决方法。因此,当您退出下拉列表时,您可以更改纯文本控件的值。


以下是示例。


 Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl,Cancel As Boolean)
If ContentControl.Type = wdContentControlDropdownList Then
Dim conText As ContentControl
Set conText = ThisDocument.SelectContentControlsByTitle(" Text1")。Item(1)
conText.Range.Text = ContentControl.Range.Text
End if
End Sub


最好的问候,


Terry






Hello Good Day. I'm trying to have the value of my Plain Text Control based on the selection made by the user on my Drop Down list. I'm using content control. Thanks for the help.

解决方案

Hi Ej Ochoa,

I didn't find such an event which could do this. Document_ContentControlBeforeContentUpdate could catch the changes on Drop Down list, but due to all content controls share the same event, if you want to set value of a content control in this event, you will get error. I suggest you use Document_ContentControlOnExit as workaround. So you could change value of your Plain Text Control when you exit the Drop Down list.

Here is the example.

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
If ContentControl.Type = wdContentControlDropdownList Then
Dim conText As ContentControl
Set conText=ThisDocument.SelectContentControlsByTitle("Text1").Item(1)
conText.Range.Text = ContentControl.Range.Text
End If
End Sub

Best Regards,

Terry




这篇关于如何在ms字中自动填充下拉内容控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆