View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Mail Merge & Find/Replace

If the page numbering is really the thing that is controlling this, format
the page numbering in the mailmerge main document so that it starts at one,
rather than continuing from the previous section (you may already have that)
AND instead of using a { NUMPAGE } field to get the total number of pages in
each letter, use a { SECTIONPAGES } field. Then your individual letters
will be numbered correctly.

However, adding the following code

With NewDoc
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="CR", Replacewith:="^l",
MatchWildcards:=False, Wrap:=wdFindContinue, _ Forward:=True) = True
Loop
End With
End With

before the commands

NewDoc.Range.Fields.Update
NewDoc.SaveAs FldrPath & fnames(i)

in the

Private Sub app_MailMergeAfterMerge(ByVal Doc As Document, ByVal DocResult
As Document)

event in the Addin, should (I haven't tested it) do the replacement on each
individual document. I would suggest however that you try and avoid having
to do it.

--
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

"what4893" wrote in message
ups.com...
Sorry for not listing what I'm replacing. I have an Access database
that is tied to some ASP .NET pages I have written. Each month I need
to create letters with some of the data that was entered from the
previous month. The problem is that I need the data split into nice
even columns and the data is coming out in one long stream. So, what I
did is where ever I need a line break I have programmed my ASP .NET
page to output CR then once in Word I just do a find and replace to
convert all of the CR tags to ^l which is the new line character
recognized by Word. Unfortunately if I just use ^l in my ASP output
code Word considers it as text and doesn't interpret the character.

As you mentioned it would be much easier to execute a single long mail
merge and then run the find and replace. This is true except that I
need all the letters broken up into separate files so I can save them
to different locations AND if the letters aren't separated the pages
numbers inserted by Word will say 1 of 76 or however many letters are
created in the one long mail merge. The reason I need the dynamic page
numbers is that the letters are of differing lengths each month
depending on how much information is inputed. Thanks for your quick
response.