Mail Merge - Creating Separate Documents

J

Jennifer

Hello! Does anyone know how to create a mail merge that
will produce separate documents instead of one running
document? Please email me with the answer at
(e-mail address removed)

THANKS
 
D

Doug Robbins - Word MVP

Hi Jennifer,

The following macro will split the document into separate documents for each
record in the datasource.

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
 
D

Doug Robbins - Word MVP

Sorry Jennifer,

Here is the macro now:

Sub splitter()

' splitter Macro

' Macro created by Doug Robbins to save each letter created by a mailmerge
as a separate file.

Dim Letters As Integer, Counter As Integer
Letters = ActiveDocument.Sections.Count
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "Myletter" & LTrim$(Str$(Counter))
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.Sections(2).PageSetup.SectionStart = wdSectionContinuous
ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend

End Sub

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
 
J

Jennifer Ready

I was unable to open this macro. I will try to search for
this splitter macro in word?

THanks
 
Joined
Jun 5, 2008
Messages
1
Reaction score
0
Splitter Macro

This works great but I have one question. Rather then using the DocName of MyLetter plus the record ID as the letter name, I would like to use a column in my excel sheet. This column is a client number. How can I take that column from the sheet and use it. I also have it as the last field in the mege doc.

THanks.
 
Joined
Mar 10, 2010
Messages
1
Reaction score
0
Naming file using content from merged document

This macro works great. In addition to what it does, rather than naming each separate file with a common prefix and a sequential number, would it be possible to name it using one of the fields that were merged into the document, such as the name the letter is addressed to?

Or does somebody know of another macro that could be run after the separate documents are created that will rename the file using one of the merged fields within it?

I'm very new to this so any help would be GREATLY appreciated!

Thanks.
 
Joined
Apr 20, 2010
Messages
9
Reaction score
0
Bump and another linked query

If you're still reading this forum Doug Robbins, thank you.

I have the same question as TexMex4Me - I want to be able to amend the macro so it names each document with data from one of the merge fields (a name or an ID no - not necessarily sequential) and the existing document name. So MarReports would become say 3672MarReports, 3675MarReports etc or CLSMarReports, SALMarReports etc.

Also have a nuisance issue which I think is easier to solve.
The master & merged single document have Font Arial & single line spacing whereas the created documents are going to the new default of calibri & 10pt below each line/1.5 line spacing, whatever it is. How can I force the new doc to take up all the paramCters of the merged one (it does keep a wierd margin I have in place to allow for an offcentre letterhead, so I don't think it's entirely defaulting to the Normal template)

Am going to cross post to the Word Document Management section of this newsgroup as I'm not sure this is a beginners' issue!

I have tried a search, because I'm sure this has probably been answered elsewhere, but couldn't even find the original post, let alone one answering this ... I'm obviously rubbish at defining my terms.

Thanks in anticipation.


Query duplicated at
https://www.pcreview.co.uk/forums/showthread.php?p=13939116
 
Last edited:
Joined
Apr 20, 2010
Messages
9
Reaction score
0
I've had a look around & it seems that it is possible to pick up the nth to the (n+x)th characters in a document. This means that we could get round the naming problem if we insert the relevant field right at the start of the document (so that after merging each letter starts with the correct reference) then replace LTrim$(Str$(Counter))in the line
Code:
  DocName = "Myletter" & LTrim$(Str$(Counter))
with code that will pick up the first (let's say) 4 characters.

Problem is, as someone who has only used VBA in Excel before, I don't know the syntax or how to find out the character number of a particular bit of text. (Well, I can guess the latter, but is a return a single character? or none? or 80?) And Word's own VBA help files & articles - on & offline - are still above my head.

So, can anyone help with this simpler question?

And any idea what to do to make the new document it creates have the same formatting as the source document rather than that of 'Normal'? Is there an equivalent of the Excel PasteSpecial command retaining the formatting?

I have tried recording a macro of my own to find out but ... well that's another post ...

Thanks in advance for any light anyone can shed on this.
 
Joined
Sep 16, 2010
Messages
1
Reaction score
0
Hi All
Am facing a problem with the splitter script in the mail merge option. this is what i did
entered the below mentioned VB script in a module and save the word 2003 document as a macro enabled document and reopened it. Had the mail merge made into a letters rather than a normal word document. And when i clicked run for the macro the macro did not make any progress and the document did not split based on the mail merge.

The scrip that i used is mentioned below. would need some help on how can i run this scrip and split my document and also save the created documents based on individual names.

Sub splitter()
Dim Letters As Integer, Counter As Integer
Letters = ActiveDocument.Sections.Count
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "Myletter" & LTrim$(Str$(Counter))
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.Sections(2).PageSetup.SectionStart = wdSectionContinuous
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 3
Wend
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top