Solved

Trim spaces from a mail merged field in Word 2007

Posted on 2015-02-20
6
388 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Access MDB/PDF 21 32
Cells protection in Excel 7 22
Excel Worksheet Function of VBA Code 5 18
Column Formatting 4 6
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now