在 Word 2003、2007、2010 文档中嵌入自定义数据

发布于 2024-11-06 04:51:56 字数 289 浏览 2 评论 0原文

我正在开发一个 Word 插件,该插件必须与 2003 年开始的所有 Word 版本兼容。功能所需的要求之一是能够在文档中嵌入任意长度的自定义数据。 Word.Document.CustomDocumentProperties 适用于所有必需的版本,但不幸的是限制了数据的大小。在研究过程中,我还发现 Word.Document.CustomXML 可能是我需要的解决方案。但是,我无法确定此属性是否适用于 Word 2003。此外,必须可以对自定义数据执行 CRUD 操作,但据我所知,CustomXML 部分仅提供添加和检索数据的方法。我应该如何应对这个要求?

I'm working on a Word plugin that has to be compatible with all Word versions beginning with 2003. One of the requirements needed for a feature is the ability to embed custom data of any length in a document. The Word.Document.CustomDocumentProperties works for all the required versions but unfortunately limits the size of the data. While researching, I also discovered that Word.Document.CustomXML might be the solution I need. However, I was not able to find out if this property works properly for Word 2003. Additionally, performing CRUD operations must be possible on the custom data but from what I see the CustomXML part only provides methods to add and retrieve the data. How should I tackle this requirement?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沒落の蓅哖 2024-11-13 04:51:56

关于 CustomXML,请记住 Microsoft 去年遇到的专利问题,该问题导致 Office 2007 中删除了该功能(至少在美国)。请参阅此博客了解详细信息 。我记得删除仅限于美国版,而Office 2010 MS则采用了另一种方法。但这意味着您依赖于客户 Office 安装的补丁状态。

您可以查看 Word 文档变量而不是文档属性。从 Word 95 开始就支持它们,并且可以将其视为附加到文档中的 INI 文件。我在将 XML 结构仅保存在一个文档变量中(如果需要,还可以加密 XML 内容)方面取得了很好的经验。

但是,您可以只读取或写入文档变量(或删除它们)。 Word对象模型本身无法保证CRUD操作;这是你的应用程序负责的。

还请记住(如果您的文档发出并通过电子邮件附件返回),您的某些客户可能会使用某些元数据删除工具;我在合法市场上见过很多它的使用。这些工具可以删除文档变量和 Office 文档属性。对于 Office 文档(Word、Excel),您的数据不可能 100% 安全地保留在文档中。

Concerning CustomXML, please remember the patent issue Microsoft encountered last year, which lead to a removal of the feature in Office 2007 (at least in the US). See this blog for details. I remember that the removal was limited to the US edition, and that for Office 2010 MS uses another approach. But that means that you depend from the patch state of your customer's Office installation.

You may look into Word document variables instead of document properties. They are supported ever since Word 95 and can be seen as an INI file attached to the document. I've made good experiences with a XML structure saved just in one document variable (the XML content you can also encrypt, if necessary).

However, you can just read or write document variables (or delete them). There is no way to assure CRUD operations through the Word object model in itself; it's your application which is responsible.

Please keep in mind too, that (if your documents go out and come back thr' e-mail attachments), that some of your customers may use some meta-data removal tool; I've seen the use of it in the legal market a lot. Those tools can remove document variables and Office document properties. With Office documents (Word, Excel), it is not possible to have a 100% security that your data will remain in the document.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文