在Microsoft Word文档中存储任意元数据 [英] Storing arbitrary meta-data in Microsoft Word document

查看:358
本文介绍了在Microsoft Word文档中存储任意元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Word文档中存储自定义元数据. 文档属性"限制为255个字节,但我的数据为>> 10k

I need to store custom meta-data in a Word document. The 'document properties' are limited to 255 bytes but I have data which is >> 10k

我们正在使用VBA编写单词扩展名以与我们的应用程序交互,并希望将我们的应用程序数据存储在word文档中.这样的想法是,用户可以只共享word文档,而无需共享我们应用程序的任何其他数据文件.

We are using VBA to write a word extension to interact with our application and want to have our application data stored in the word document. The idea is that that the user can share just the word document without sharing any other data files of our application.

有没有人想过如何在Office 2003+文档中有效地存储任意元数据?

Has anyone ideas how to store arbitrary meta-data efficently in Office 2003+ documents?

推荐答案

只需在VBA编辑器的即时窗口中尝试此操作:

Just tried this in the VBA editor immediate window:

ActiveDocument.Variables.Add "foo", String(10000, ".")

? Len(ActiveDocument.Variables("foo"))
10000

文档变量与文档一起存储.正如我刚刚发现的那样,它们似乎最多可以包含65280个Unicode字符(在Word 2003中进行了测试; 更新::此限制在Word 2007和2010中相同).

Document variables are stored with the document. They seem to go up to 65280 Unicode characters, as I just found out (tested in Word 2003; Update: This limit is the same in Word 2007 and 2010).

如果您担心数据接近60k,建议您将其拆分为几个变量,或者在存储之前对其进行压缩.

If you fear to get near the 60k for your data, I'd recommend either splitting it over several variables, or compressing it before you store it. This post shows some options to do that in VBA.

这篇关于在Microsoft Word文档中存储任意元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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