Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / August 2004

Tip: Looking for answers? Try searching our database.

create and save separate files from mail merge result

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gellione - 03 Aug 2004 07:07 GMT
i have a 108 page document containing 108 individualised copies of a letter, created by mail-merging Access data into a Word letter template. is there a way to break the long document into 108 separate documents and save them using data from the mail merge [name] fields as the filenames?

the long document contains page breaks before each new individualised letter so i guess it's possible to use a macro to creat a new document from each page break. but macros i've recorded with Word fail because they give each document the same filename. i don't know how to create macros outside of Word. and would appreciate any suggestions.

thank you.
Graham Mayor - 03 Aug 2004 07:52 GMT
Once you have merged the fields are no longer available so they can't be
used to name the documents. For an alternative plan see
http://www.gmayor.com/individual_merge_letters.htm

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> i have a 108 page document containing 108 individualised copies of a
> letter, created by mail-merging Access data into a Word letter
[quoted text clipped - 10 lines]
>
> thank you.
gellione - 04 Aug 2004 02:27 GMT
thanks graham, that's a big help.

one non-essential tweaking question: is there a way to have the macro append the first few characters of text in each document to the resulting filenames?

> Once you have merged the fields are no longer available so they can't be
> used to name the documents. For an alternative plan see
> http://www.gmayor.com/individual_merge_letters.htm
Graham Mayor - 04 Aug 2004 09:18 GMT
The following will add the first word of each merge letter to the start of
the filenames. If that is derived from a field then that will reflect the
fieldname.
You can change the relevant bit of code to select the Word(s) you want to
include and of course change the path to match your own requirements

Sub SplitMerge()
' splitter Macro
' Macro created 16-08-98 by Doug Robbins to save each letter created by a
' mailmerge as a separate file.
' With minor modifications by Graham Mayor 10-02-03& 04-08-2004

Dim mask As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"

Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
   Application.ScreenUpdating = False

' Start of changed section
   Selection.HomeKey Unit:=wdStory
   Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
   sName = Selection
   Docname = "D:\My Documents\Test\Merge\" _
   & sName & " " & Format(Date, mask) & " " & LTrim$(Str$(Counter))
'End of changed section

   ActiveDocument.Sections.First.Range.Cut
   Documents.Add
   Selection.Paste
   ActiveDocument.SaveAs FileName:=Docname, _
   FileFormat:=wdFormatDocument
   ActiveWindow.Close
   Counter = Counter + 1
   Application.ScreenUpdating = True
Wend

End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> thanks graham, that's a big help.
>
[quoted text clipped - 14 lines]
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<
gellione - 05 Aug 2004 02:59 GMT
thanks! that's perfect. i appreciate your help.
jc

> The following will add the first word of each merge letter to the start of
> the filenames. If that is derived from a field then that will reflect the
[quoted text clipped - 56 lines]
> >> Word MVP web site http://word.mvps.org
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<
Graham Mayor - 05 Aug 2004 07:29 GMT
With a slight modification, you can delete the Word you used to name the
document, which might be handy if you inserted the extra field to provide
the name used -

Sub SplitbyDate()
' splitter Macro
' Macro created 16-08-98 by Doug Robbins to save each letter created by a
' mailmerge as a separate file.
' With minor modifications by Graham Mayor 10-02-03& 04-08-2004

Dim mask As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"

Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
   Application.ScreenUpdating = False
   Selection.HomeKey Unit:=wdStory
   Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
   sName = Selection
   Selection.Delete Unit:=wdCharacter, Count:=1
   Docname = "D:\My Documents\Test\Merge\" _
   & sName & " " & Format(Date, mask) & " " & LTrim$(Str$(Counter))
   ActiveDocument.Sections.First.Range.Cut
   Documents.Add
   Selection.Paste
   ActiveDocument.SaveAs FileName:=Docname, _
   FileFormat:=wdFormatDocument
   ActiveWindow.Close
   Counter = Counter + 1
   Application.ScreenUpdating = True
Wend

End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> thanks! that's perfect. i appreciate your help.
> jc
[quoted text clipped - 68 lines]
>>>> Word MVP web site http://word.mvps.org
>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.