A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Break up Mail Merge into separate documents



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2004, 10:38 PM
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

Hi Doug,
Thank you for your reply. I am new to macros. I created
the catalog and created the 2nd mail merge, but when I try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text of
the macro I made from your previous message. Thank you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter, 1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" & DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves creating a

separate
catalog type mailmerge maindocument which creates a word

document containing
a table in each row of which would be your data from the

database that you
want to use as the filename.

You first execute that mailmerge, then save that file and

close it. Then
execute the mailmerge that you want to create the

separate files from and
with the
result of that on the screen, run a macro containing the

following code
and when the File open dialog appears, select the file

containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName As

Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter, 1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit

where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,

FileFormat:= _
wdFormatDocument, LockComments:=False,

Password:="",
AddToRecentFiles:= _
True, WritePassword:="",

ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,

SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote in

message
...
Hi,
A mail merge produces one large document. I would like

to
know if there is a way to chop up this document into
separate documents.

For example, if I run a mail merge for a personalized
letter to 30 people, now I have one document -- but I

want
to have 30 separate letters, each of which I would like

to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to save
with file names that allow me to easily identify which
letter goes with which email. for instance, the file

name
could be based upon 1 or more of the merge codes in the
letter.
thanks,
Craig


.

  #2  
Old May 5th, 2004, 03:14 AM
Doug Robbins - Word MVP
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

What line of code is highlighted when the error occurs. Are there any lines
in red which would indicate a missing line break.

Also undoubtably you will need to change the path to the folder in which the
documents are being saved.

See the article "What do I do with macros sent to me by other newsgroup
readers to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
wrote in message
...
Hi Doug,
Thank you for your reply. I am new to macros. I created
the catalog and created the 2nd mail merge, but when I try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text of
the macro I made from your previous message. Thank you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter, 1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" & DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves creating a

separate
catalog type mailmerge maindocument which creates a word

document containing
a table in each row of which would be your data from the

database that you
want to use as the filename.

You first execute that mailmerge, then save that file and

close it. Then
execute the mailmerge that you want to create the

separate files from and
with the
result of that on the screen, run a macro containing the

following code
and when the File open dialog appears, select the file

containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName As

Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter, 1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit

where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,

FileFormat:= _
wdFormatDocument, LockComments:=False,

Password:="",
AddToRecentFiles:= _
True, WritePassword:="",

ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,

SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote in

message
...
Hi,
A mail merge produces one large document. I would like

to
know if there is a way to chop up this document into
separate documents.

For example, if I run a mail merge for a personalized
letter to 30 people, now I have one document -- but I

want
to have 30 separate letters, each of which I would like

to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to save
with file names that allow me to easily identify which
letter goes with which email. for instance, the file

name
could be based upon 1 or more of the merge codes in the
letter.
thanks,
Craig


.


  #3  
Old May 5th, 2004, 02:57 PM
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

Hi Doug,
Sorry, I meant to include the highlighted line. It is the
second line: "As String"

I know that I need to change the path, but the macro
doesn't get to that point.

The below text is in red. Any help you might provide would
be appreciated. Thank you for sending the link bout sent
macros -- I will read that in the meantime.
Craig

ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False

-----Original Message-----
What line of code is highlighted when the error occurs.

Are there any lines
in red which would indicate a missing line break.

Also undoubtably you will need to change the path to the

folder in which the
documents are being saved.

See the article "What do I do with macros sent to me by

other newsgroup
readers to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
wrote in message
...
Hi Doug,
Thank you for your reply. I am new to macros. I created
the catalog and created the 2nd mail merge, but when I

try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text of
the macro I made from your previous message. Thank you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves

creating a
separate
catalog type mailmerge maindocument which creates a

word
document containing
a table in each row of which would be your data from

the
database that you
want to use as the filename.

You first execute that mailmerge, then save that file

and
close it. Then
execute the mailmerge that you want to create the

separate files from and
with the
result of that on the screen, run a macro containing

the
following code
and when the File open dialog appears, select the file

containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName As

Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit

where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,

FileFormat:= _
wdFormatDocument, LockComments:=False,

Password:="",
AddToRecentFiles:= _
True, WritePassword:="",

ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,

SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote in

message
...
Hi,
A mail merge produces one large document. I would

like
to
know if there is a way to chop up this document into
separate documents.

For example, if I run a mail merge for a personalized
letter to 30 people, now I have one document -- but I

want
to have 30 separate letters, each of which I would

like
to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to

save
with file names that allow me to easily identify

which
letter goes with which email. for instance, the file

name
could be based upon 1 or more of the merge codes in

the
letter.
thanks,
Craig

.


.

  #4  
Old May 6th, 2004, 01:49 PM
Doug Robbins - Word MVP
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

That command is in red because the email program has inserted line breaks
without the visual basic _ line break character.

Place the cusor at the beginning of each line following a line that
terminates with a _ use backspace to remove the newline inserted by the
email program.

Likewise, all of this was originally one line of code

Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
--
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
wrote in message
...
Hi Doug,
Sorry, I meant to include the highlighted line. It is the
second line: "As String"

I know that I need to change the path, but the macro
doesn't get to that point.

The below text is in red. Any help you might provide would
be appreciated. Thank you for sending the link bout sent
macros -- I will read that in the meantime.
Craig

ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False

-----Original Message-----
What line of code is highlighted when the error occurs.

Are there any lines
in red which would indicate a missing line break.

Also undoubtably you will need to change the path to the

folder in which the
documents are being saved.

See the article "What do I do with macros sent to me by

other newsgroup
readers to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
wrote in message
...
Hi Doug,
Thank you for your reply. I am new to macros. I created
the catalog and created the 2nd mail merge, but when I

try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text of
the macro I made from your previous message. Thank you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves

creating a
separate
catalog type mailmerge maindocument which creates a

word
document containing
a table in each row of which would be your data from

the
database that you
want to use as the filename.

You first execute that mailmerge, then save that file

and
close it. Then
execute the mailmerge that you want to create the
separate files from and
with the
result of that on the screen, run a macro containing

the
following code
and when the File open dialog appears, select the file
containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &
DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote in
message
...
Hi,
A mail merge produces one large document. I would

like
to
know if there is a way to chop up this document into
separate documents.

For example, if I run a mail merge for a personalized
letter to 30 people, now I have one document -- but I
want
to have 30 separate letters, each of which I would

like
to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to

save
with file names that allow me to easily identify

which
letter goes with which email. for instance, the file
name
could be based upon 1 or more of the merge codes in

the
letter.
thanks,
Craig

.


.


  #5  
Old May 14th, 2004, 05:49 PM
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

Thank you, Doug. Now I have 2 remaining questions, and if
you could answer these I would be very appeciative.

1. Your macro runs great, except that no document is saved
for the last record in the catalog document. The last
section of the mail merge remains open on screen, and no
doc is saved. Any idea why?
2. I'd like to modify the macro so that the doc name is in
the second column of the catalog. How might I do this? In
the first column of the catalog, I have the email of the
person to whom the document should be sent, and in the
second column I have the document name. For example:

c:\mail merge docs\bob123.doc

Any and all help appreciated.
Thank you,
Craig

-----Original Message-----
That command is in red because the email program has

inserted line breaks
without the visual basic _ line break character.

Place the cusor at the beginning of each line following a

line that
terminates with a _ use backspace to remove the newline

inserted by the
email program.

Likewise, all of this was originally one line of code

Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
--
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
wrote in message
...
Hi Doug,
Sorry, I meant to include the highlighted line. It is

the
second line: "As String"

I know that I need to change the path, but the macro
doesn't get to that point.

The below text is in red. Any help you might provide

would
be appreciated. Thank you for sending the link bout sent
macros -- I will read that in the meantime.
Craig

ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False

-----Original Message-----
What line of code is highlighted when the error occurs.

Are there any lines
in red which would indicate a missing line break.

Also undoubtably you will need to change the path to

the
folder in which the
documents are being saved.

See the article "What do I do with macros sent to me by

other newsgroup
readers to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
wrote in message
...
Hi Doug,
Thank you for your reply. I am new to macros. I

created
the catalog and created the 2nd mail merge, but when

I
try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text

of
the macro I made from your previous message. Thank

you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName

As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves

creating a
separate
catalog type mailmerge maindocument which creates a

word
document containing
a table in each row of which would be your data from

the
database that you
want to use as the filename.

You first execute that mailmerge, then save that

file
and
close it. Then
execute the mailmerge that you want to create the
separate files from and
with the
result of that on the screen, run a macro containing

the
following code
and when the File open dialog appears, select the

file
containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName

As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to

suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &
DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote

in
message
...
Hi,
A mail merge produces one large document. I would

like
to
know if there is a way to chop up this document

into
separate documents.

For example, if I run a mail merge for a

personalized
letter to 30 people, now I have one document --

but I
want
to have 30 separate letters, each of which I would

like
to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to

save
with file names that allow me to easily identify

which
letter goes with which email. for instance, the

file
name
could be based upon 1 or more of the merge codes

in
the
letter.
thanks,
Craig

.


.


.

  #6  
Old May 14th, 2004, 05:55 PM
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

In case it is relevant to my last 2 questions, I did
change one line of your macro. I changed the line:

DocumentName = "I:\WorkArea\Documentum\" & DocName.Text

To:

DocumentName = DocName.Text

I did this because I have the full path, file name and
extension in my catalog already. For example: C:\mail
merge docs\bob123.doc. I didn't think this would make a
difference explaining why the last doc does not save, but
thought I'd let you know, just in case.
Thank you,
Craig

-----Original Message-----
That command is in red because the email program has

inserted line breaks
without the visual basic _ line break character.

Place the cusor at the beginning of each line following a

line that
terminates with a _ use backspace to remove the newline

inserted by the
email program.

Likewise, all of this was originally one line of code

Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
--
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
wrote in message
...
Hi Doug,
Sorry, I meant to include the highlighted line. It is

the
second line: "As String"

I know that I need to change the path, but the macro
doesn't get to that point.

The below text is in red. Any help you might provide

would
be appreciated. Thank you for sending the link bout sent
macros -- I will read that in the meantime.
Craig

ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False

-----Original Message-----
What line of code is highlighted when the error occurs.

Are there any lines
in red which would indicate a missing line break.

Also undoubtably you will need to change the path to

the
folder in which the
documents are being saved.

See the article "What do I do with macros sent to me by

other newsgroup
readers to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
wrote in message
...
Hi Doug,
Thank you for your reply. I am new to macros. I

created
the catalog and created the 2nd mail merge, but when

I
try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text

of
the macro I made from your previous message. Thank

you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName

As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &

DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves

creating a
separate
catalog type mailmerge maindocument which creates a

word
document containing
a table in each row of which would be your data from

the
database that you
want to use as the filename.

You first execute that mailmerge, then save that

file
and
close it. Then
execute the mailmerge that you want to create the
separate files from and
with the
result of that on the screen, run a macro containing

the
following code
and when the File open dialog appears, select the

file
containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName

As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,

1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to

suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &
DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote

in
message
...
Hi,
A mail merge produces one large document. I would

like
to
know if there is a way to chop up this document

into
separate documents.

For example, if I run a mail merge for a

personalized
letter to 30 people, now I have one document --

but I
want
to have 30 separate letters, each of which I would

like
to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to

save
with file names that allow me to easily identify

which
letter goes with which email. for instance, the

file
name
could be based upon 1 or more of the merge codes

in
the
letter.
thanks,
Craig

.


.


.

  #7  
Old May 15th, 2004, 06:24 AM
Doug Robbins - Word MVP
external usenet poster
 
Posts: n/a
Default Break up Mail Merge into separate documents

Change

While Counter oblist.Tables(1).Rows.Count

to

While Counter = oblist.Tables(1).Rows.Count

if the docname is in the second column, then use

Set DocName = oblist.Tables(1).Cell(Counter, 2).Range

in place of

Set DocName = oblist.Tables(1).Cell(Counter, 1).Range

--
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
wrote in message
...
Thank you, Doug. Now I have 2 remaining questions, and if
you could answer these I would be very appeciative.

1. Your macro runs great, except that no document is saved
for the last record in the catalog document. The last
section of the mail merge remains open on screen, and no
doc is saved. Any idea why?
2. I'd like to modify the macro so that the doc name is in
the second column of the catalog. How might I do this? In
the first column of the catalog, I have the email of the
person to whom the document should be sent, and in the
second column I have the document name. For example:

c:\mail merge docs\bob123.doc

Any and all help appreciated.
Thank you,
Craig

-----Original Message-----
That command is in red because the email program has

inserted line breaks
without the visual basic _ line break character.

Place the cusor at the beginning of each line following a

line that
terminates with a _ use backspace to remove the newline

inserted by the
email program.

Likewise, all of this was originally one line of code

Dim Source As Document, oblist As Document, DocName As
Range, DocumentName
As String
--
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
wrote in message
...
Hi Doug,
Sorry, I meant to include the highlighted line. It is

the
second line: "As String"

I know that I need to change the path, but the macro
doesn't get to that point.

The below text is in red. Any help you might provide

would
be appreciated. Thank you for sending the link bout sent
macros -- I will read that in the meantime.
Craig

ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False

-----Original Message-----
What line of code is highlighted when the error occurs.
Are there any lines
in red which would indicate a missing line break.

Also undoubtably you will need to change the path to

the
folder in which the
documents are being saved.

See the article "What do I do with macros sent to me by
other newsgroup
readers to help me out?" at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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
wrote in message
...
Hi Doug,
Thank you for your reply. I am new to macros. I

created
the catalog and created the 2nd mail merge, but when

I
try
to execute the macro, I receive a VBA error:

Compile Error: Syntax Error

Any idea what I may be doing wrong. Here is the text

of
the macro I made from your previous message. Thank

you
again so much for the help.
Craig

Sub Splitter()
'
' Splitter Macro
' Macro created 5/4/2004 by Craig Friedman
'
Dim Source As Document, oblist As Document, DocName

As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,
1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &
DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
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

-----Original Message-----
Here's a method that I have used that involves
creating a
separate
catalog type mailmerge maindocument which creates a
word
document containing
a table in each row of which would be your data from
the
database that you
want to use as the filename.

You first execute that mailmerge, then save that

file
and
close it. Then
execute the mailmerge that you want to create the
separate files from and
with the
result of that on the screen, run a macro containing
the
following code
and when the File open dialog appears, select the

file
containing the table
created by the first mailmerge

Dim Source As Document, oblist As Document, DocName

As
Range, DocumentName
As String
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
While Counter oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(Counter,
1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to

suit
where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" &
DocName.Text
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
ActiveDocument.SaveAs filename:=DocumentName,
FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="",
AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveWindow.Close
Counter = Counter + 1
Wend


--
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
"Craig" wrote

in
message
...
Hi,
A mail merge produces one large document. I would
like
to
know if there is a way to chop up this document

into
separate documents.

For example, if I run a mail merge for a

personalized
letter to 30 people, now I have one document --

but I
want
to have 30 separate letters, each of which I would
like
to
email to the correct recipient.

Any ideas? Ideally, I would like the 30 letters to
save
with file names that allow me to easily identify
which
letter goes with which email. for instance, the

file
name
could be based upon 1 or more of the merge codes

in
the
letter.
thanks,
Craig

.


.


.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.