views:

350

answers:

2

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

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.

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

+3  A: 

Just tried this in the VBA editor immediate window:

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

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

Document variables are stored with the document. They seem to go up to 65280 bytes, as I just found out (tested in Word 2003).

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.

Tomalak
A: 

It fits not exactly your requirements because it does not work with Word 2003. However, it still might be interesting to you (otherwise I recommend you to use document variables as suggested by Tomalak):

In Word 2007 you may embed arbitrary XML documents in a Word document as Custom XML.

An example is described ins this article on MSDN: How to: Add Custom XML Parts to Documents by Using Application-Level Add-Ins

0xA3