vba VBA将Word Doc中下拉列表的选定值复制到特定的Excel单元格中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13053491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA to copy selected value of dropdown in Word Doc into specific Excel cell
提问by user1771800
I am trying to return the text from a dropdown box that is selected on a Word form.
我正在尝试从 Word 表单上选择的下拉框中返回文本。
The word doc is a survey that contains a form with several dropdown boxes. I want to copy the value that the survey respondent selected from each dropdown into specific cells in Excel.
doc 这个词是一个调查,其中包含一个带有多个下拉框的表单。我想将调查受访者从每个下拉列表中选择的值复制到 Excel 中的特定单元格中。
I have tried things such as:
我尝试过诸如以下的事情:
Activedocument.DropDowns("DropDown1").Value;
Activedocument.DropDowns("DropDown1").Text;
Activedocument.DropDowns("DropDown1").SelectedValue;
Activedocument.Shapes("DropDown1").Value etc etc.
Current applicable parts of my code:
我的代码的当前适用部分:
Dim dd14 As FormFields
With ActiveDocument
Set dd14 = ActiveDocument.FormFields("Dropdown14").DropDown.Value
Cells(iRow + 1, "H") = dd14
End With
回答by scott
To reference the value for a legacy form dropdown field to get the value (which is the index, not the text of the selected item) the code is:
要引用旧表单下拉字段的值以获取值(即索引,而不是所选项目的文本),代码为:
activedocument.FormFields("dropdown1").DropDown.value