GTS
Tue Feb 22 15:42:40 CST 2005
"Jean-Guy Marcil" <no-spam@leaveme.alone> wrote in message
news:OjiY7hRGFHA.2156@TK2MSFTNGP10.phx.gbl...
> Kris was telling us:
> Kris nous racontait que :
>
> > "Greg" wrote:
> >
> >> Graham,
> >>
> >> Maybe something like this will get you started:
> >>
> >> Sub SpiltName()
> >> Dim oStr As String
> >> Dim myArray
> >> oStr = ActiveDocument.Bookmarks("FullName").Range.Text
> >> myArray = Split(oStr)
> >> MsgBox myArray(0)
> >> MsgBox myArray(1)
> >> End Sub
> >>
> > Blimey that was quick. So if I make a bookmark "Fullname" that would
> > be populated with mergefield FULLUSER would this subroutine work as
> > is? How do I make sure the sub runs after the merge data is imported?
>
> It depends what you want to do and how the merge is being done at the
> present.
>
> You stated that you might do this and that with the split information.
> Wihthout knowing ore, it is difficult to help.
>
> If the merge is run manually, you would have to call the macro after the
> merge is done. But you would have to manipulate the FULLUSER field before
> creating the individual letters because once the letters are merged, the
> fields are gone (and so is the bookmark).
>
> But really, it will be complicated to do what you want with the
mergefields
> in Word. It would be a lot , and I mean a lot, easier to split the info in
> the database.
> Ant let this be a lesson to whoever designed the database: You never
create
> a database with multiple info in the same field (like first and last name,
> or city and state, age and gender, etc.)
>
> Otherwise, you could assign a unique paragraph (or character) style (or a
> font colour) to the string that will hold the FULLUSER info, and then,
after
> the merge, run a macro to locate all those strings and do something with
> them. It would be a bit messy and might take a while to run if you have
> 1000+ letters, but it would work.
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org
>
Thank you for your input. To answer your questions:
I wish to print the split information on the letter. So the letter ends
something like:
Yours Sincerely
MERGEFIELD "FULL NAME"
TEL ......
Email full.name@whatever.co.uk
The merge is not run manually. The software package we use passes just one
record at a time to Word, along with the letter name that is required. Word
then opens the correct letter, merges the record, produces a new document
and prints that one document. So only one letter at a time is produced, but
there is a large number of different letters. There merging and printing
process is fully automated, there is no user interaction with Word at all.
Each letter needs the user's email address.
The existing plan is to use a lookup table in Excel, inserting a database in
every letter just to look for FULLNAME in the lookup table and return a
correct email address for each users name.
To me, this method seems cumbersome, and of course the excel table will have
to be open all the time.
I thought a VB solution to split the name would be more gracefull and save
having to have Excel running all the time...
Graham