Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2015, 07:41 AM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default Hyperlinks in IF...THEN Mail Merge

Hello,



I am having a problem using hyperlinks within IF THEN conditional statements with Mail Merge in MS Word 2010. I have been trying to use quick parts->Field->Hyperlink, however, when I run the mail merge, the hyperlink isn't there, only the hyperlink text. Any ideas?

Cheers
Reply With Quote
  #2  
Old 12-15-2015, 07:48 AM
gmayor's Avatar
gmayor gmayor is offline Hyperlinks in IF...THEN Mail Merge Windows 10 Hyperlinks in IF...THEN Mail Merge Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
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

Hyperlinks are a bit fiddly to implement in mail merge - see http://www.gmayor.com/hyperlink_merge_fields.htm
__________________
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 12-15-2015, 08:42 AM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

Thank you very much Graham!

Will this work if I need to share the document with several other people, who won't have this add in on their version of word. I can download it, but I don't think having 10+ people also download it to see the hyperlinks is a great solution for me.
Reply With Quote
  #4  
Old 12-15-2015, 09:34 AM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

Would it be possible to create a macro that would go in and add hyperlinks after or before the mail merge?
Reply With Quote
  #5  
Old 12-15-2015, 11:33 AM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

I found this post on a Microsoft forum here:

"By default, if you insert a mailmerge field into a hyperlink field, the hyperlinks will all show the first record’s address as the 'Text to display' text. Here's how you can do get a mailmerge to display your preferred default 'Text to display' text instead:
1. Disregarding mergefield issues for the moment, insert a hyperlink into the document in the normal way, choosing whatever 'Click Here' text you want in the 'Text to display' box.
2. Select the inserted hyperlink and press Shift-F9 to expose its field code.
3. Replace everything in the field after 'HYPERLINK' with your mergefield.
4. Select the field and press F9 to update the display.

In Word 2007 & later, you can make the display text variable also, by following these additional steps:
5. Position the cursor anywhere within the display text.
6. Insert a mergefield pointing to whatever data field you want to use for the display text (this could even be the same field as used at step 3 above).
7. Delete all of the previous display text either side of your last-inserted mergefield (note that this field will likely have updated already).
8. Execute the merge.
9. After merging to a new document, use Ctrl-A, F9 to update all fields. Without this, the mergefield hover text won’t update to the correct targets.

Now, as for implementing your IF tests along the foregoing lines, you should be able to use:
{HYPERLINK "{IF{MERGEFIELD M_CXdotLIBORTEST}= "N" "http://www.federalreserve.gov/releases/h15" "http://online.wsj.com/mdc/public/page/2_3020-moneyrate.html"}"}
for the hyperlink field code (step 3) and:
{IF{MERGEFIELD M_CXdotLIBORTEST}= "N" "Federal Reserve Statistical Release" "Wall Street Journal"}
for the display text (step 6), respectively. As you can see, the HYPERLINK field code reverses the arrangement you had, by putting the IF test inside the HYPERLINK field rather than the other way around; HYPERLINK fields inside IF tests will always come out as plain text."




I am having an issue with this code. For my link, it is either there in some cases, or not there in other cases. (If Variable='Y', the hyperlink exists), (If Variable!='Y', there is no hyperlink).

I have figured out how to have the correct hyperlink with the proper text- but when I complete the Mail Merge, the link is appearing in all cases (even when Variable!=Y) rather than just when Variable =Y.

Last edited by ljg713; 12-15-2015 at 12:00 PM. Reason: Clarify
Reply With Quote
  #6  
Old 12-15-2015, 01:32 PM
macropod's Avatar
macropod macropod is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge 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

Have you read the Mailmerge Hyperlink ‘Click Here’ Insertion topic in the 'sticky' Mailmerge Tips and Tricks thread at the top of this forum:
https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 12-15-2015, 01:45 PM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

Hi, thanks for replying!
Yep. I've read that and it was helpful for getting the proper link and text to appear.

All that is giving me trouble is the fact that the link is still appearing when it should not. My code is like this:

{HYPERLINK "{IF {Mergefield Variable}="Y" "http://www.google.com" ""}"}

So I only want the link to appear if the Variable=Y, and it does. But it is still appearing when the Variables !=Y. I'm guessing it has something to do with the IF being inside the Hyperlink and not outside, but I'm not sure how to work around that to get it to go away when Variable!=Y. I hope this makes sense.

Last edited by ljg713; 12-15-2015 at 01:45 PM. Reason: typo
Reply With Quote
  #8  
Old 12-15-2015, 02:21 PM
macropod's Avatar
macropod macropod is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge 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

The problem you're having is that you're trying to conditionally display a hyperlink, not vary it. Aside from your field coding being incorrect, Word will always output a hyperlink with such a field (even an ostensibly empty one consisting of just a space). The correct field coding is:
{HYPERLINK "{IF{Mergefield Variable}= "Y" "http://www.google.com" " "}"}
Note the difference in spacing in the field code.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 12-15-2015, 02:33 PM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

Thanks Paul! I tried that coding though with the proper spacing and am still having the link show up in all of the merges, not just the ones where the variable=y. Any ideas?
Reply With Quote
  #10  
Old 12-15-2015, 02:36 PM
macropod's Avatar
macropod macropod is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge 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

Did you implement step 9 of the process you quoted in post #5?
Quote:
9. After merging to a new document, use Ctrl-A, F9 to update all fields. Without this, the mergefield hover text won’t update to the correct targets
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 12-15-2015, 02:37 PM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

Yep, did that.
Reply With Quote
  #12  
Old 12-15-2015, 02:51 PM
macropod's Avatar
macropod macropod is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge 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 works correctly for me. Check your field coding.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 12-15-2015, 02:56 PM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

Now the link itself is not appearing, but the text still is. Sorry! I'm definitely doing something wrong here...
Reply With Quote
  #14  
Old 12-15-2015, 03:00 PM
macropod's Avatar
macropod macropod is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge 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 ljg713 View Post
I'm definitely doing something wrong here...
Can't argue with that!

Can you attach the problem document - with your field code intact - to a post (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 12-15-2015, 03:06 PM
ljg713 ljg713 is offline Hyperlinks in IF...THEN Mail Merge Windows 7 64bit Hyperlinks in IF...THEN Mail Merge Office 2010 64bit
Novice
Hyperlinks in IF...THEN Mail Merge
 
Join Date: Dec 2015
Posts: 20
ljg713 is on a distinguished road
Default

This will require a bit of work to get rid of sensitize data, but I will post back tomorrow if I'm still unable to figure it out the issue between now and then! I will report back either way.

Cheers
Reply With Quote
Reply

Tags
hyperlink, hyperlink in mail merge, mailmerge



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlinks in IF...THEN Mail Merge Mail Merge is Deleting objects in my header and footer during the merge bgranzow Mail Merge 9 06-05-2015 05:03 AM
Mail merge how to link mail merge field value to a column heading dsummers Mail Merge 1 05-08-2014 02:59 PM
E-Mail attachment (PDF) opening up Hyperlinks instead of PDF slee Outlook 0 11-06-2013 07:29 PM
Mail merge from Excel to Word and include hyperlinks chay Mail Merge 5 09-28-2013 01:16 AM
Hyperlinks in IF...THEN Mail Merge Saving INDV mail merges During the mail merge sedain121 Mail Merge 2 10-04-2011 07:52 PM

Other Forums: Access Forums

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


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