我无法从 ContentControl 获取选定的值,也无法设置我想要的值 [英] I'm not able to get the selected value from ContentControl and I'm not able also to set the value I want

查看:33
本文介绍了我无法从 ContentControl 获取选定的值,也无法设置我想要的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个从属下拉列表,用户可以在其中选择第一个下拉列表,而所有其他从属下拉列表将自动更改.

I'm trying to make a dependent drop-down list where the user may select the first drop-down list and all the other dependent drop-down list will change automatically.

Select Case ContentControl.Title
  Case "T1_1"
   Select Case ContentControl.DropdownListEntries.Item.Value
     Case "male"

      ActiveDocument.SelectContentControlsByTitle("T1_2").Item(1).Value = "male"
      ActiveDocument.SelectContentControlsByTitle("T1_3").Item(1).Value = "male"
      ActiveDocument.SelectContentControlsByTitle("T1_4").Item(1).Value = "male"

     Case "female"

      ActiveDocument.SelectContentControlsByTitle("T1_2").Item(1).Value = "female"
      ActiveDocument.SelectContentControlsByTitle("T1_3").Item(1).Value = "female"
      ActiveDocument.SelectContentControlsByTitle("T1_4").Item(1).Value = "female"

  End Select

我无法获得所选值男性或女性",也无法设置我想要的值.

I'm not able to get the selected value "male or female" and I'm not able also to set the value I want.

推荐答案

我前段时间查了一下,Microsoft 只是忘记让您查询 DropDown-ContentControl 的选定 value.
只能得到ContentControl.Range.Text,所以如果需要查找对应的速记值,就得循环遍历:

From what I looked up some time ago, Microsoft just forgot to let you query the selected value of a DropDown-ContentControl.
You can only get ContentControl.Range.Text, so if you need to look up the corresponding shorthand-value, you have to loop through:

Public Function getCCDD_value(cc As ContentControl) As String
     getCCDD_value = ""
     For Each Item In cc.DropdownListEntries
         If Item.Text = cc.Range.Text Then
             getCCDD_value = Item.Value
         End If
     Next
End Function

对于更改,您可以简单地设置 ContentControl 的 .Range.Text.它必须匹配现有的 dropdown-listentries-text(区分大小写),以便之后返回正确的 value.

For changing, you can simply set the ContentControl's .Range.Text. It must match an existing dropdown-listentries-text (case sensitive) in order to return the correct value afterwards.

这篇关于我无法从 ContentControl 获取选定的值,也无法设置我想要的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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