Unbound Merge Field

L

Len Robichaud

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.
 
J

Jonathan West

Len Robichaud said:
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.

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.


--
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
 
C

Cindy M.

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
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.

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 :)
 
J

Jonathan West

Cindy M. said:
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.

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
 
L

Len Robichaud

Thanks...

Jonathan West said:
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


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top