I am trying to automate a Word document from Access. My vba code works to
open the doc from a template and pass data to populate all of the bookmarks
with the appropriate text (using selection).
I want some of the data I pass to appear in multiple locations (Mystring1 to
the header, paragraph 1, etc.). It appears that each bookmark can only
reference one location. I could say Bookmark1 = Mystring1, Bookmark7 =
Mystring1, Bookmark12 = Mystring1 but that seems inefficient.
How can I pass data that will auto-fill multiple locations with a single
string with a single command? I know I can create a merge field but I don't
want to bind the document to a data source.
Jonathan West - 07 Jun 2007 15:14 GMT
>I am trying to automate a Word document from Access. My vba code works to
>open the doc from a template and pass data to populate all of the bookmarks
[quoted text clipped - 8 lines]
> string with a single command? I know I can create a merge field but I
> don't want to bind the document to a data source.
Create some custom document properties, and then create DOCPROPERTY fields
in all the appropriate places. Update the fields by pushing your data into
the appropriate items in the CustomDocumentProperties collection, and then
update all fields so the new data shows up in the document.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
Cindy M. - 08 Jun 2007 11:03 GMT
Hi Len,
An alternative to Jonathan's approach would be to use REF fields elsewhere in
the document (Insert/Cross Reference can do this for you) to duplicate what
appears in the original bookmarks.
> I am trying to automate a Word document from Access. My vba code works to
> open the doc from a template and pass data to populate all of the bookmarks
[quoted text clipped - 8 lines]
> string with a single command? I know I can create a merge field but I don't
> want to bind the document to a data source.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Jonathan West - 08 Jun 2007 11:51 GMT
> Hi Len,
>
[quoted text clipped - 3 lines]
> what
> appears in the original bookmarks.
While I agree that Condy's is an alternative approach, remember to ensure
that the bookmark is re-inserted when you put text there. Selecting a
bookmark and typing over it (or inserting text using VBA) deletes the
bookmark. Take a look here for how to get round the problem.
Inserting text at a bookmark without deleting the bookmark
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Len Robichaud - 08 Jun 2007 15:03 GMT
Thanks...
>> Hi Len,
>>
[quoted text clipped - 11 lines]
> Inserting text at a bookmark without deleting the bookmark
> http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm