Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-01-2016, 02:55 PM
dfin dfin is offline Bookmark - add two merge fields Windows 10 Bookmark - add two merge fields Office 2016
Novice
Bookmark - add two merge fields
 
Join Date: Sep 2016
Posts: 3
dfin is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 09-01-2016, 09:05 PM
gmayor's Avatar
gmayor gmayor is offline Bookmark - add two merge fields Windows 10 Bookmark - add two merge fields Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 09-02-2016, 03:02 AM
macropod's Avatar
macropod macropod is offline Bookmark - add two merge fields Windows 7 64bit Bookmark - add two merge fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmayor View Post
You cannot have more than one 'Clientname' bookmark in the finished merge.
Indeed, you can't even have one such bookmark in a finished merge document or more than one in the mailmerge main document used to generate it.

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]
Reply With Quote
  #4  
Old 09-02-2016, 12:56 PM
dfin dfin is offline Bookmark - add two merge fields Windows 10 Bookmark - add two merge fields Office 2016
Novice
Bookmark - add two merge fields
 
Join Date: Sep 2016
Posts: 3
dfin is on a distinguished road
Default

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
Reply With Quote
  #5  
Old 09-03-2016, 12:56 AM
macropod's Avatar
macropod macropod is offline Bookmark - add two merge fields Windows 7 64bit Bookmark - add two merge fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #6  
Old 09-06-2016, 10:08 PM
dfin dfin is offline Bookmark - add two merge fields Windows 10 Bookmark - add two merge fields Office 2016
Novice
Bookmark - add two merge fields
 
Join Date: Sep 2016
Posts: 3
dfin is on a distinguished road
Default

That makes sense - thanks.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bookmark - add two merge fields Mail Merge fields merge incorrectly and won't fix. marym Mail Merge 3 04-09-2016 05:17 AM
Bookmark - add two merge fields Displaying FORMTEXT fields when merge fields are empty or null sfkHooper Mail Merge 6 01-19-2016 04:24 PM
Bookmark - add two merge fields Mail merge bookmark (again) Nisio07 Mail Merge 7 10-21-2014 03:34 PM
Bookmark - add two merge fields merge fields disappear in merge doc but prints mdod Word 1 07-19-2013 06:33 PM
Bookmark - add two merge fields Conditional merge fields in mail merge Aude Mail Merge 1 01-06-2012 07:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft