Merging one line out of multiple lines

S

Sonja

I have copied merged an address field that is all one field. There is a
total of three lines in this field , customer name is on the first line,
address on 2nd line and so on. I would like to take line one the customer
name and place it into another field. Example:
Dear (customer name from first line of address field)

Can you tell me if this is possible?

Thanks in advance for your help!
 
D

Doug Robbins - Word MVP

It is not that easy to do after the merge. I would manipulate the data
source. If it is a table in a Word Document, Insert a new column after the
last column and then use the following macro

Dim i As Long
Dim company As Range
With ActiveDocument.Tables(1)
For i = 2 To .Rows.Count
Set company = .Cell(i, 1).Range
company.Collapse wdCollapseStart
company.Select
.Cell(i, .Columns.Count).Range.Text =
Selection.Bookmarks("\line").Range.Text
Next i
End With

This assumes that the address is in the first field. If it is not, change
the 1 in the line

Set company = .Cell(i, 1).Range

to the number of the column that contains the address.

If your data source is not a table in a Word document, use a catalog or
directory type mail merge to create a table that contains the data, then
insert a row at the top of the table into which you enter the names of the
merge fields and then add the column and run the above macro.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

Sonja

Thank you Doug

My data source is from Access database. The information is copied into
Access and then merged into my mailmerge document.
 
D

Doug Robbins - Word MVP

Unless using the original source is simpler. Open the table in Access and
select all of the records by clicking in the top left corner adjacent to the
first field name and then copy and paste into a Word document, and then add
one more column and run the macro that I gave you.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top