Solved

Trim spaces from a mail merged field in Word 2007

Posted on 2015-02-20
6
415 Views
Last Modified: 2016-02-11
I am building mail merged letters in Word 2007 from a .csv file.  I am exporting the file from a 3rd party application so do not have the ability to trim the field prior to the .csv file creation.  Is there a way in Word 2007 to trim a field that has spaces that need to be removed. (ex. Company Name field has the potential for a lot of trailing spaces.)
Is there a way to insert a space into a field after a Semicolon? (ex. Address field that has the Street, City, State and Zip as one field with no spaces following the semicolons)
0
Comment
Question by:PJ_KD
  • 2
  • 2
  • 2
6 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 250 total points
ID: 40621559
Use the Find and Replace function (Ctrl+H).
 
1. Find: two spaces.
Replace: one space.
 
Repeat several time.
 
2. Find: semicolon
Replace: semicolon and space.
 
Then repeat number 1.
0
 

Author Comment

by:PJ_KD
ID: 40621576
Is there no automated means to do this like the trim function in Excel?
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40621581
Only through a macro. But it only takes about 1 minute to do the above.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 40621587
We are generally reliant on Word Field operations during a mail merge and that doesn't provide a way of editing part of a field. It could be done with VBA, but it would be better to do it before presenting the file to the merge.

If you can use the file as an input to the mail merge, you should be able to input it to some other process, edit it, and present the result to the merge.

Excel can open .csv files, so that would be the best. Word can open .csv files and the text can then be converted into tables for mail merge input, but the process gets tricky if there are embedded separator characters (commas) in the fields.
0
 

Author Closing Comment

by:PJ_KD
ID: 40626529
I appreciate the input from  you both.  I was really hoping for an automated solution, if that was possible since there will be many letters occurring for the foreseeable  future.  I revised the mail merge main document so that the deletion of the spaces will not be an issue.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40626880
You could use VBA to automate the procedure thus:

1. Read the supplied file line, by line
2. Do the required modifications and output to another file (both spaces and semi-colon)
3, Run the mail merge with the revised file as input.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS excel check if Links exist 5 35
conditional formatting 4 42
Unhide very hidden sheets with password 22 44
Excel - DATEDIF error #NUM 6 19
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question