Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
DFIA DFIA is offline
external usenet poster
 
Posts: 1
Default Pick first name of full name in word merge

I Have a data base in Excel with the first cell containing the full name of a
person.
I want to customized a word letter starting with "Dear Frank" by using mail
merge and by picking up only the given name (first name) of the full name in
the cell of the data base.
Is there a way to do that?
Thank you.
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Pick first name of full name in word merge

If possible, create an additional column in the Excel data source.

Otherwise, as long as
a. you are using Office 2002 or later and are connecting using the
default method (OLE DB)
b. you have already connected to the data source manually
c. you should be able to use something like the following approach to
return an extra column that contains only the first name.

Suppose you are getting your data from Sheet1 of the workbook, and the
name of the column containing the full name is "fullname" and you do not
already have a column called firstname.

Open the VBA Editor and type the following in the Immediate window:

?ActiveDocument.MailMerge.Datasource.Querystring

and press the Enter key.

You should see something like

SELECT * FROM `Sheet1$`

Create a new Sub as follows:

Sub splitthename()
ActiveDocument.MailMerge.DataSource.QueryString = _
" SELECT left(fullname,instr(fullname & ' ',' ')-1)" & _
" AS [firstname], * FROM `Sheet1$`"
End Sub

In other words, you need to keep the same
FROM `Sheet1$`
as before. If you don't like those backquotes, you can use
FROM [Sheet1$]


Run that sub, then use Edit Recipients to verify that you are seeing a
new column called firstname and that it contains the data you want. If
the Sub does not execute correctly, the connection will probably be lost
and you will either have to recreate it manually before trying again, or
write a sub that does an OpenDataSource.

Once you are getting the data you want, you should be able to save your
document, close it, then re-open it to verify that the query still works.

Peter Jamieson

http://tips.pjmsn.me.uk

On 01/12/2009 15:35, DFIA wrote:
I Have a data base in Excel with the first cell containing the full name of a
person.
I want to customized a word letter starting with "Dear Frank" by using mail
merge and by picking up only the given name (first name) of the full name in
the cell of the data base.
Is there a way to do that?
Thank you.

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
Pick chapters to create a full document Buggelsgaard Microsoft Word Help 1 October 2nd 09 02:51 PM
Mail Merge will not pick up recipients from Word table. It fills. Mary Mailmerge 2 December 20th 06 07:20 AM
how do i get mail merge to pick up different names per line oakbrook Mailmerge 1 December 19th 05 09:18 PM
compare and merge does not pick up deleted text Joanne Microsoft Word Help 0 June 29th 05 05:19 PM
Word mail merge doesn't pick up the addresses in Access database. Julie Tables 1 November 24th 04 01:26 AM


All times are GMT +1. The time now is 04:49 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"