Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2006

Tip: Looking for answers? Try searching our database.

Can I truncate merged text - eg using Left, Right, etc?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 03 Jul 2006 11:38 GMT
Hi - My mergefield returns a string whicih is a random number from 1 to a
million but with four characters at the end. Eg 12345.fed or 1.fed, etc. I'd
like to remove the .fed suffix and just display the numbered portion of the
mergefield.  Can i do this?
Many thanks
James
Doug Robbins - Word MVP - 03 Jul 2006 11:52 GMT
The best place to manipulate data is in the data source.

You cannot use Left, Right etc. in a merge field and there is no formatting
switch that can be used to cause only the numerals to be displayed.

The only possible way of doing it is if you have the data being inserted
into the cells of  table and have the paragraph containing the mergefield
right aligned with a negative right indent in the paragraph definition that
causes the unwanted part of the data to "disappear" out the right-hand side
of the cell.

Of course, after executing the merge, you could use Edit>Replace to replace
the unwanted part of the data with nothing.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi - My mergefield returns a string whicih is a random number from 1 to a
> million but with four characters at the end. Eg 12345.fed or 1.fed, etc.
[quoted text clipped - 4 lines]
> Many thanks
> James
James - 03 Jul 2006 14:22 GMT
Unfortnately I cant get at the data source as it comes from a 3rd party
application and we can't run macros either (for "security" reasons).
Nevertheless, your main suggestion re aligning table cells works perfectly!
I'm very grateful.
Thanks
James

> The best place to manipulate data is in the data source.
>
[quoted text clipped - 18 lines]
> > Many thanks
> > James
Peter Jamieson - 03 Jul 2006 11:53 GMT
You may be able to use a numeric format switch to do this - e.g. instead of

{ MERGEFIELD myfield }

use

{ MERGEFIELD myfield \#0 }

(You can Alt-f9 to show the field codes).

It works in simple cases but you need to test with your own data.

Other than that, there are no "right" "left" type functions in the Word
field "language" but if you use VBA to open the data source you can issue
SQL that uses "left", "right" type functions if they are supported by the
data source (e.g. it is possible if your data comes from Access but not if
it is coming from Word), and it is sometimes possible to use a DATABASE
field to do something similar.

Peter Jamieson

> Hi - My mergefield returns a string whicih is a random number from 1 to a
> million but with four characters at the end. Eg 12345.fed or 1.fed, etc.
[quoted text clipped - 4 lines]
> Many thanks
> James
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.