vba 使用 Word ContentControl DatePicker 如何获取值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10823874/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 16:21:09  来源:igfitidea点击:

With a Word ContentControl DatePicker how do i get the value?

vbams-wordword-vbaword-2010

提问by QueueHammer

I have a ContentControl that is a DatePicker in a word document. I'm trying to use it to populate some value in a code behind but I cant seem to get the value out of it.

我有一个 ContentControl,它是 Word 文档中的 DatePicker。我正在尝试使用它在后面的代码中填充一些值,但我似乎无法从中获取值。

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, _
    Cancel As Boolean)

None of the properties on ContentControl are close to .Value or .Text. I have seen other content controls use:

ContentControl 上的所有属性都不接近 .Value 或 .Text。我已经看到其他内容控件使用:

ContentControl.DropdownListEntries(1).Text
ContentControl.DropdownListEntries(1).Value

This, as expected for a DatePicker, does not work but it is the only property of ContentControl that returns anything close to the value I want.

正如 DatePicker 所预期的那样,这不起作用,但它是 ContentControl 的唯一属性,可以返回接近我想要的值的任何内容。

How do i get the date from the DatePicker ContentControl?

如何从 DatePicker ContentControl 获取日期?

回答by Siddharth Rout

Is this what you are trying?

这是你正在尝试的吗?

Private Sub Document_ContentControlOnExit(ByVal ContentControl _
As ContentControl, Cancel As Boolean)
    MsgBox ContentControl.Range.Text
End Sub

SNAPSHOT

快照

enter image description here

在此处输入图片说明