A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to do String Manipulations on a Merge Field?



 
 
Thread Tools Display Modes
  #1  
Old September 13th 07, 06:59 PM posted to microsoft.public.word.mailmerge.fields
Lynda[_2_]
external usenet poster
 
Posts: 19
Default How to do String Manipulations on a Merge Field?

Is it possible to find the last or first character(s) in a mail merge field?
For example, I want to check a merge field that contains 4 characters and I
just want to do an if-then-else statement on the final character. For
example, if Right(mergefield) = 1, then do something, else do something
different. I can't seem to find any information on string manipulations in
Word. I am using Word 2003.

Thanks for your help.

Lynda


Ads
  #2  
Old September 13th 07, 07:55 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,583
Default How to do String Manipulations on a Merge Field?

There are no string functions such as left(), mid(), right() but you can use
wildcards at the left hand eend or right hand end of the second comparand
(but not both ends at once), e.g.

{ IF "{ MERGEFIELD myfield }" = "*1" "the rightmost character is a 1" "the
rightmost character is not a 1" }

It doesn't work for text longer than around 128 characters (or maybe 64, I
forget).

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Lynda" wrote in message
...
Is it possible to find the last or first character(s) in a mail merge
field? For example, I want to check a merge field that contains 4
characters and I just want to do an if-then-else statement on the final
character. For example, if Right(mergefield) = 1, then do something, else
do something different. I can't seem to find any information on string
manipulations in Word. I am using Word 2003.

Thanks for your help.

Lynda


  #3  
Old September 13th 07, 10:09 PM posted to microsoft.public.word.mailmerge.fields
macropod
external usenet poster
 
Posts: 1,002
Default How to do String Manipulations on a Merge Field?

Hi Lynda,

Alternatively, to check that the string is exactly 4 characters long and ends in a 1:
{ IF "{ MERGEFIELD myfield }" = "???1" "the last character is a 1 at the 4th position" "the last character is NOT a 1 at the 4th
position" }
or to check the 4th character in a potentially longer string:
{ IF "{ MERGEFIELD myfield }" = "???1*" "the 4th character is a 1 " "the 4th character is NOT a 1" }

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Peter Jamieson" wrote in message ...
There are no string functions such as left(), mid(), right() but you can use wildcards at the left hand eend or right hand end of
the second comparand (but not both ends at once), e.g.

{ IF "{ MERGEFIELD myfield }" = "*1" "the rightmost character is a 1" "the rightmost character is not a 1" }

It doesn't work for text longer than around 128 characters (or maybe 64, I forget).

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Lynda" wrote in message ...
Is it possible to find the last or first character(s) in a mail merge field? For example, I want to check a merge field that
contains 4 characters and I just want to do an if-then-else statement on the final character. For example, if Right(mergefield)
= 1, then do something, else do something different. I can't seem to find any information on string manipulations in Word. I am
using Word 2003.

Thanks for your help.

Lynda



  #4  
Old September 14th 07, 04:57 PM posted to microsoft.public.word.mailmerge.fields
Lynda[_2_]
external usenet poster
 
Posts: 19
Default How to do String Manipulations on a Merge Field?

Thanks so much! That is exactly what I was looking for.

Lynda

"macropod" wrote in message
...
Hi Lynda,

Alternatively, to check that the string is exactly 4 characters long and
ends in a 1:
{ IF "{ MERGEFIELD myfield }" = "???1" "the last character is a 1 at the
4th position" "the last character is NOT a 1 at the 4th position" }
or to check the 4th character in a potentially longer string:
{ IF "{ MERGEFIELD myfield }" = "???1*" "the 4th character is a 1 " "the
4th character is NOT a 1" }

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Peter Jamieson" wrote in message
...
There are no string functions such as left(), mid(), right() but you can
use wildcards at the left hand eend or right hand end of the second
comparand (but not both ends at once), e.g.

{ IF "{ MERGEFIELD myfield }" = "*1" "the rightmost character is a 1"
"the rightmost character is not a 1" }

It doesn't work for text longer than around 128 characters (or maybe 64,
I forget).

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Lynda" wrote in message
...
Is it possible to find the last or first character(s) in a mail merge
field? For example, I want to check a merge field that contains 4
characters and I just want to do an if-then-else statement on the final
character. For example, if Right(mergefield) = 1, then do something,
else do something different. I can't seem to find any information on
string manipulations in Word. I am using Word 2003.

Thanks for your help.

Lynda





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit SQL String in Mail Merge Epoh Rio Mailmerge 1 December 7th 06 11:42 PM
Word needs rectangle text manipulations (like emacs) alw Microsoft Word Help 2 April 4th 06 04:39 PM
Is there a way to find and replace a text string with a field nam. Jeff Janoski Microsoft Word Help 2 May 26th 05 05:47 AM
How to replace all instances of a text string with a field referen Robert Kleinschmidt Microsoft Word Help 2 February 16th 05 01:34 AM
Query String in Mail Merge XP karen lyons via OfficeKB.com Mailmerge 0 January 13th 05 11:50 PM


All times are GMT +1. The time now is 05:58 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.