"Morgan" wrote:
> Hello all,
>
> I'm going nuts trying to figure out how to create templates that
> populate from a data source, are completely editable, yet also have
> some way of marking and retrieving text from the populated locations
> in the document.
>
> The obvious answer to this is to use either form fields or bookmarks,
> since they both contain ranges and they can both be referenced with an
> associated name property. And they do indeed work, but they are easy
> to unintentionally delete by the users, which makes later parsing and
> retrieval of text from said fields impossible.
>
> I ran across one interesting idea to get around this limitation, which
> is to assign each form field its own section, and then to set those
> sections to ProtectedForForms = True. This ALMOST worked - which is,
> of course, even more frustrating than total failure :).
> Unfortunately, Word can't have multiple section breaks - even
> continuous section breaks - in a single line, and a number of my
> templates need to have four or five fields in close proximity. Having
> line breaks between them would be unacceptable for many of the
> templates, particularly the legal documents.
>
> A similar limitation occurs with bookmarks, but there I can't both
> protect the bookmark and assure that it won't be typed over
> accidentally. If I protect them then they can't be manually edited,
> but if I don't it only takes one long select and over-type and they're
> gone.
>
> I had previously been using Document Property fields to populate the
> document using the Custom Document Properties, auto-updating them,
> then detaching the fields from their references to make them
> editable. The problem is that once that's been done, I can't
> programmatically retrieve information from those fields, which makes
> future data gathering impossible - or manual, which is essentially the
> same for me :)
>
> I came up with a little function to find and store the index locations
> of each field in the document for later reference if I ended up having
> to use a type of field that doesn't have a name property - like a
> Quote field, for example - but I always end up running into the
> protection issue.
>
> The only thing I can think of other than that is to have the field
> areas linked to button-type macros that activate on double-click, but
> it would be a huge pain to convert all of my templates to use such a
> system, and I really don't like the idea of implementing such a code-
> intensive task for every field in a document if it's at all possible
> to avoid it.
>
> If necessary, I'll just eschew my dreams of data retrieval and stick
> with the Document Property fields, but I'd *really* prefer not to.
>
> Surely this isn't such a wild concept - can anyone help?
If you can wait until all those involved with editing/maintaining the
documents you a referring to can use Word 2007, then you can use Content
Controls which can be set to "Cannot be deleted".
See Greg Maxey's tip page on these controls:
http://gregmaxey.mvps.org/Mapped_Content_Control.htm
Later, if you really need to (or want to!), you can use XML to retrieve/set
the information in the content controls...