Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
DaveS DaveS is offline
external usenet poster
 
Posts: 6
Default eliminate trailing spaces on a mail merge field

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

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default eliminate trailing spaces on a mail merge field

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
--

Graham Mayor - Word MVP

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



"DaveS" wrote in message
...
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



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to eliminate double spaced address field in mail merge Chris Millerick Mailmerge 5 January 24th 12 09:55 PM
eliminate trailing spaces in a mail merge field DaveS Mailmerge 1 June 6th 07 06:56 AM
Trailing spaces in columns Dustin Page Layout 1 August 31st 06 08:05 PM
How do I eliminate spaces resulting from blank mail merge fields? KTCOMP Mailmerge 1 November 16th 05 06:48 PM
Leading spaces in Mail Merge field not printing Cindy M -WordMVP- Mailmerge 0 November 30th 04 05:25 PM


All times are GMT +1. The time now is 08:16 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"