#1
|
|||
|
|||
Bookmark - add two merge fields
I've figured out how to insert a merge field in a bookmark as follows: ActiveDocument.Bookmarks("Clientname").Range.Field s.Add ActiveDocument.Bookmarks("Clientname").Range, wdFieldMergeField, "FIRST_NAME" What I want to do now is insert two merge fields (plus a space in between), e.g.: FirstName LastName How is this done? I've only been able to do it by using two bookmarks so far. Thanks |
#2
|
||||
|
||||
I fear this may be doomed to failure. If this is a mail merge document, how is it to be used? Bookmark names must be unique. You cannot have more than one 'Clientname' bookmark in the finished merge.
What is the point of the exercise?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
||||
|
||||
Quote:
dfin: More to the point though, why are you trying to add mergefields via VBA instead of using a document that already contains them?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
This is kind or a complicated, non standard, setup - the template gets opened by another application (a legal CRM system). When the template is opened, there is a Word form displayed where additional info is collected from the user. The user then clicks a button and the merge happens.
In this case, depending on the user's input on the Word form, I sometimes need to dynamically insert a merge field in the template so the CRM can populate it. I can't have the merge field permanently in the template, because depending on the user's input, it may not be required. If I want to insert the merge fields for the firstname and lastname from the CRM, it seems like I have to use two separate bookmarks. Thanks, Dave |
#5
|
||||
|
||||
It would be a lot simpler to have the two mergefields in the base document, using a single bookmarked range, so you can delete that range's contents when not needed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
That makes sense - thanks.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge fields merge incorrectly and won't fix. | marym | Mail Merge | 3 | 04-09-2016 05:17 AM |
Displaying FORMTEXT fields when merge fields are empty or null | sfkHooper | Mail Merge | 6 | 01-19-2016 04:24 PM |
Mail merge bookmark (again) | Nisio07 | Mail Merge | 7 | 10-21-2014 03:34 PM |
merge fields disappear in merge doc but prints | mdod | Word | 1 | 07-19-2013 06:33 PM |
Conditional merge fields in mail merge | Aude | Mail Merge | 1 | 01-06-2012 07:38 PM |