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 / March 2004

Tip: Looking for answers? Try searching our database.

Saving single mailmerge into multiple files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 15 Mar 2004 22:55 GMT
I have been trying to save the results of a mail merge
into separate files using VBA. I have had some limited
success, but where I keep having trouble is with the
formatting. My original file is 4 pages on 11X17 paper
with the last page formatted differently than the other 3
resulting in 2 sections per report. When I run the macro
that copies and pastes the first 2 sections of the file it
does not keep the 11X17 paper size or any of the other
formatting and as a results I get 5 pages due to the extra
section break. Even if I make the last section break a
continuous break I still end up with 5 pages. Does any
body know how I can break up this original merge into
multiple files and preserve the original 11x17 formatting?

I have tried using the VBA code listed at word.mvps.org,
but because I have 2 sections per document I can't get
subdocs to work. I have also tried the code Doug Robbins
posted earlier on this forum and that's where I am losing
the formatting.
Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS - 16 Mar 2004 09:31 GMT
Hi Frank,

I haven't tested the following.

Dim Letters As Integer, Counter As Integer, myrange As Range, sourcedoc As
Document, newdoc As Document
Set sourcdoc = ActiveDocument
Letters = sourcedoc.Sections.Count
Counter = 1
While Counter < Letters
   DocName = "Myletter" & LTrim$(Str$(Counter))
   Set myrange = sourcedoc.Sections.First.Range
   myrange.End = sourcedoc.Sections(2).Range.End
   Set newdoc = Documents.Add("My11x17template.dot")
   newdoc.Range = myrange
   myrange.Cut
   newdoc.Sections(3).PageSetup.SectionStart = wdSectionContinuous
   newdoc.SaveAs FileName:=DocName, FileFormat:= _
       wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
       True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
       False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
       SaveAsAOCELetter:=False
   newdoc.Close
   Counter = Counter + 2
Wend
End Sub

Note that it relies on you creating a template (My11x17template.dot) in the
11 x 17 format that you require.

Signature

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested.  Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP

>I have been trying to save the results of a mail merge
> into separate files using VBA. I have had some limited
[quoted text clipped - 15 lines]
> posted earlier on this forum and that's where I am losing
> the formatting.
 
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.