View Single Post
 
Old 10-07-2014, 08:08 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
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

Word fields can't really do any meaningful string testing for parts of a string and are even more limited for string splitting. That said, it would be possible to test whether the field ends with 5%, for example, and vary where the whole of the output for that field goes, accordingly.

So, if your field outputs '£84.00 + VAT @ 20%', or '£84.00 + VAT @ 5%', you could use two fields, to conditionally output the whole field in either column:
{IF{MERGEFIELD Amount}= "*20%" {MERGEFIELD Amount}}
{IF{MERGEFIELD Amount}= "*5%" {MERGEFIELD Amount}}
or:
{IF«Amount»= "*20%" «Amount}}
{IF«Amount»= "*5%" «Amount}}
where 'Amount' is your mergefield's name

Splitting the output components is more complicated, involving some circumlocution. The following will return the £ values:
{IF{MERGEFIELD Amount}= "*20%" {={MERGEFIELD Amount}-.2 \# "£,0.00"}}
{IF{MERGEFIELD Amount}= "*5%" {={MERGEFIELD Amount}-.05 \# "£,0.00"}}
or:
{IF«Amount»= "*20%" {=«Amount»-.2 \# "£,0.00"}}
{IF«Amount»= "*5%" «Amount»-.05 \# "£,0.00"}}
The following will return the % portions:
{IF{MERGEFIELD Amount}= "*20%" "+ VAT @ 20%"}
{IF{MERGEFIELD Amount}= "*5%" "+ VAT @ 5%"}
or:
{IF«Amount»= "*20%" "+ VAT @ 20%"}
{IF«Amount»= "*5%" "+ VAT @ 5%"}

Note: The field brace pairs (i.e. '{ }') for the above examples are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues. Likewise, you can't type or copy & paste the chevrons (i.e. '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar. The spaces represented in the field constructions are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote