R
rich
Ok I'm a real newbie so forgive me if I say anything stupid.
Basically I have a little script which splits out the Letters document
that is created at the end of a mail merge when you click 'Edit
individual letters'. This script saves each individual document with
a seperate filename (date and counter+1) what I would like to do is
save each one of these documents with the name contained in the first
field of my mail merge.
As you can see (in the bits comented out) I've had a go but I cant get
the bookmark 'cell' to pass over to the 'Edit individual letters' for
each recipient, I basically get the first document saved with the
right name no problem but I'm guessing the others dont save as there's
only one bookmark. I thought if i bookmarked the first field during
the mail merge process it would bookmark all the corisponding fields
in the letters document.
Does anyone have any ideas of how to do this or a work around?
Thanks
-------------------------------------------
Sub Splitter()
' splitter Macro
' saves each letter created by a mailmerge as a separate file.
Dim mask As String
'Dim Name As String
'Name = ActiveDocument.Bookmarks("cell").Range.Text
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "c:\feedback\" & Format(Date, mask) & " " &
LTrim$(Str$(Counter))
'DocName = "c:\feedback\" & Name
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub
Basically I have a little script which splits out the Letters document
that is created at the end of a mail merge when you click 'Edit
individual letters'. This script saves each individual document with
a seperate filename (date and counter+1) what I would like to do is
save each one of these documents with the name contained in the first
field of my mail merge.
As you can see (in the bits comented out) I've had a go but I cant get
the bookmark 'cell' to pass over to the 'Edit individual letters' for
each recipient, I basically get the first document saved with the
right name no problem but I'm guessing the others dont save as there's
only one bookmark. I thought if i bookmarked the first field during
the mail merge process it would bookmark all the corisponding fields
in the letters document.
Does anyone have any ideas of how to do this or a work around?
Thanks
-------------------------------------------
Sub Splitter()
' splitter Macro
' saves each letter created by a mailmerge as a separate file.
Dim mask As String
'Dim Name As String
'Name = ActiveDocument.Bookmarks("cell").Range.Text
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "c:\feedback\" & Format(Date, mask) & " " &
LTrim$(Str$(Counter))
'DocName = "c:\feedback\" & Name
ActiveDocument.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub