构建 Word 字段 [英] Building Word fields

查看:50
本文介绍了构建 Word 字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了将文本插入和解析到空白 Word 字段之外,还有什么方法可以使用 VBA 以编程方式将用户定义的字段和字段代码构建到我自己的模板中?此外,有没有办法让这些字段显示在可用字段列表中?

Apart from just inserting and parsing text into a blank Word field, is there any way to programmatically build user-defined fields and field codes into my own templates with VBA? Furthermore, is there a way to make these fields show up in the list of available fields?

推荐答案

我最近开发了一个使用 Word 的 MACROBUTTON 和 ADDIN 字段类型的解决方案.

I recently developed a solution that used Word's MACROBUTTON and ADDIN field types.

我发现 MACROBUTTON 很有用,因为字段内的第三个空格分隔条目(以编程方式 field.code.text)显示在 Word 中.这允许我的用户在他们四处走动时观察字段.{ MACROBUTTON NoMacro * } 会在 Word 中显示*",例如当用户双击它时它什么也不做,因为我故意没有定义一个名为NoMacro"的宏.

I found MACROBUTTON useful because the third whitespace-delimited entry inside the field (programmatically field.code.text) is displayed within Word. This allows my users to watch fields as they move around. { MACROBUTTON NoMacro * } would display an "*" in Word, e.g. And it would do nothing when the user double-clicked on it, because I have purposefully not defined a macro named "NoMacro".

ADDIN 字段不显示(除非打开了显示字段代码)并在其 field.data 属性中存储了一个隐藏字符串.使用这个字段,我可以有一个隐藏字段,其内容不能被用户看到或修改(除了如果他们打开显示字段代码",他们可以看到它是一个 ADDIN 字段(但他们不能看到/编辑数据"属性),并且他们可以像删除任何其他字段一样删除此字段.)

The ADDIN field does not display (except when display field codes is turned on) and stores a hidden string in its field.data property. Using this field I could have a hidden field the contents of which could not be seen or modified by users (excepting that if they turn on "show field codes" they can see that it is an ADDIN field (but they cannot see/edit the "data" property), and that they can delete this field just like any other field.)

我发现这些页面很有用:

I found these pages useful:

这篇关于构建 Word 字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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