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 / June 2007

Tip: Looking for answers? Try searching our database.

eliminate trailing spaces on a mail merge field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaveS - 06 Jun 2007 01:04 GMT
How can I eliminate trailing spaces on an individual merge field?

The mail merge data source is a mainframe-generated semi-colon
delimited .txt file (Excel/Access formatting is not an option)
where the fields are all a fixed-length, but the values are not always
the maximum field length. (text qualifiers such as " are not used).
I want to eliminate these spaces in the letter text.

Ex. CALL TIME field has a physical length of 20 positions, but may have
the values DURING THE DAY or AT NIGHT
Graham Mayor - 06 Jun 2007 06:21 GMT
Word does not have a function to use only part of a field. The only
practical way I can see to do this is to edit the data file to remove the
extra spaces. The following macro will remove all the extra spaces from a
semicolon delimited text file

Sub StripSpacesFromData()
   With Selection.Find
       .ClearFormatting
       .Replacement.ClearFormatting
       .Text = "[ ]@([;^13])"
       .Replacement.Text = "\1"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = True
       .MatchSoundsLike = False
       .MatchAllWordForms = False
       .Execute replace:=wdReplaceAll
   End With
End Sub

http://www.gmayor.com/installing_macro.htm
Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> How can I eliminate trailing spaces on an individual merge field?
>
[quoted text clipped - 6 lines]
> Ex. CALL TIME field has a physical length of 20 positions, but may have
> the values DURING THE DAY or AT NIGHT
 
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.