如何使用宏创建“刷新”按钮? [英] How to create a 'Refresh' button with Macros?

查看:562
本文介绍了如何使用宏创建“刷新”按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,

想知道是否有人可以为我阐明这一点。

Wondering if someone can shed some light on this for me.

请参阅下文;

红色方块中的字段是下拉列表。



我需要创建一个宏,我在红色框中填写所有列表,然后当我点击宏按钮时它会刷新回原来的状态(如下所示)

The fields in the red square are drop down lists.

I need to create a Macro where I fill out all the lists in the red box, and then when I click the Macro button it will refresh back into it's original state (as per below)



任何支持将不胜感激


Any support would be appreciated

推荐答案

您好,

Word对象模型没有提供任何方法将下拉列表内容控件重置为占位符文本。我们可以添加"选择项目"。作为条目,选择条目并将其删除,然后它将作为占位符文本在下拉列表中。 

Word Object Model doesnot provide any method to reset the drop down list content control into placeholder text. We could add "Choose an item." as a entry, select the entry and delete it, then it would be in the drop down list as placeholder text. 

您可以添加命令按钮并使用下面的代码单击命令按钮的事件。它会将所有下拉列表内容控件设置为"选择项目"。

You could add a command button and use the code below in the click event of the command button. It would set all drop down list content controls into "Choose an item."

Dim objCC As ContentControl
Dim objCE As ContentControlListEntry
For Each objCC In ActiveDocument.ContentControls
If objCC.Type = wdContentControlDropdownList Then
If objCC.DropdownListEntries(1).Text = "Choose an item." Then objCC.DropdownListEntries(1).Select
If objCC.ShowingPlaceholderText = False Then
Set objCE = objCC.DropdownListEntries.Add("Choose an item.", "", 1)
objCE.Select
End If
objCC.DropdownListEntries.Item(1).Delete
End If
Next

问候,

Celeste


这篇关于如何使用宏创建“刷新”按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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