View Full Version : [SOLVED:] Goto Command in a mail merge switch
Bob789
05-30-2017, 08:14 AM
I would like to use a goto command*or something similar in a mail merge switch.
For example:
{IF {MERGEFIELD Late_Day}=”28”{GOTO Named location A in the switch}
Named Location A would then be---> {IF L3<>"L5"{IF Quote….
Does anyone have a suggestion.* Thank you
macropod
05-30-2017, 10:52 PM
There is no such thing as a GOTO field or switch. Furthermore, it's far from clear what you're trying to achieve.
Bob789
06-01-2017, 09:57 PM
Thank you Paul. I apologize for my lack of knowledge when it comes to programming terms. I think what I am trying to askis something more closely related to a subroutine. What I am trying to have my email merge program do is anytime I come across an {IF MERGEFIELD Late_Day} =28, 30, 31, 60, 61, or 62, I want the program to go to a set subroutine and perform a set sequence of IF statements. I realize that I could just put thissubroutine/sequence in with every {IF MERGEFIELD Late_Day} but why I am trying to avoid this is that my program gets exceedingly long. Right now with the 6 {IF MERGEFIELD Late_Day} mentioned above, if I put the 25 lines of code in with each IF statement I will have 150 lines. If I can use a subroutine or something like a subroutine I can cut the 150 lines down to 25. Any suggestions. As always I appreciate your input.
macropod
06-01-2017, 11:20 PM
A mergefield can't 'call' a subroutine. If you can't modify the data source to simplify the mailmerge processing, it all has to be done by field coding. That isn't necessarily a big deal, though. Given what you've described, the basic field code might be:
{IF{MERGEFIELD Late_Day}= 28 "Text for 28" {IF{MERGEFIELD Late_Day}< 31 "Text for 29 & 30" {IF{MERGEFIELD Late_Day}= 31 "Text for 31" {IF{MERGEFIELD Late_Day}= 60 "Text for 60" {IF{MERGEFIELD Late_Day}= 61 "Text for 61" {IF{MERGEFIELD Late_Day}= 62 "Text for 62"}}}}}}
(I note you have no provision for late day = 29). It's not apparent to me where your 'if I put the 25 lines of code in with each IF statement' comes from - the above is all one logical line. If the same text output is required in multiple places, simply bookmark the entire field, then insert cross-references to the bookmark wherever required.
The alternative would be to forego mailmerge and do the whole job with VBA, but it's still not clear what your requirements are.
Bob789
06-01-2017, 11:39 PM
Can you give me an example of bookmarking the entire field and then inserting cross-references to the bookmark wherever required.
macropod
06-08-2017, 05:13 PM
This isn't rocket science - it's just basic bookmarking/cross-referencing. Bookmark something, via Insert|Bookmark, then insert a cross-reference to the bookmark, via Insert|Cross-reference.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.