Solved

Trim spaces from a mail merged field in Word 2007

Posted on 2015-02-20
6
470 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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