Splitting a directory mail merge into individual files

D

Divinite

Hi again!

I'm using MMtoDocsRev32.zip (which was a special version that allowed
me to keep bookmarks in the file).

I've got a new challenge!

I have a directory list (multiple entries for a similiar group)

District School1 Code1
District School2 Code2
District2 School1 Code1
....

My document is based off this code:
{ IF { MERGESEQ } = "1" "{ MERGEFIELD District}
" "" }{ SET District1 { MERGEFIELD District}}
{ If { District2 } <> { District1 }"
{ MERGEFIELD District }

{ MERGEFIELD SchoolName } { MERGEFIELD SchoolCode }" "{ MERGEFIELD
SchoolName } { MERGEFIELD SchoolCode }" }{ SET District2 { MERGEFIELD
District }}

When I go to complete the merge and ask it to split it into individual
documents, it says: "Your Mail Merge Main Document is not the correct
type. It must be a Mail Merge Formletter type document."

In this case, it is a formletter, but the letter contains multiple
lines per form.

Any way around this or am going to have to split all 700 by hand?

Thanks!
 
D

Doug Robbins - Word MVP

Look again at your main document type and thing that you will find that it
is a Directory type main document as that is the type that it must be for
that type of field construction to produce the desired result.

As a result, the MMtoDocs add-in cannot be used to create individual files
during the execution of the merge.

There are however other methods discussed on the website from where you
obtained the MMtoDocs addin, that can be used to split a file that is
produced by executing a merge to a new document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Divinite

I opted to try the third version "Naming the file from the data
source" as I have a set name for each of the files.

When I go to run the macro on the new merged file, it blinks and does
nothing. Macros are enabled and others run just fine. No error
message, no file popups, nothing. My file name is not in an IF
statement since I know it will always be there (it's an ID number),
but I wouldn't think that should matter since this is post-merge.

Any ideas?

Ideally, I would like this to export to PDF rather than Word. Is
there more I would need to do than changing ".doc" to ".pdf"?

Thank you,
Jessica
 
D

Doug Robbins - Word MVP

The add-in that you are using, contains the following code

Private Sub app_MailMergeBeforeRecordMerge(ByVal Doc As Document, Cancel As
Boolean)
SettingsFile = Options.DefaultFilePath(wdDocumentsPath) &
"\Settings.txt"
If Doc.MailMerge.DataSource.ActiveRecord =
Doc.MailMerge.DataSource.FirstRecord Then
n = Doc.Sections.Count - 1
Flag = False
If Doc.MailMerge.Destination = 0 Then
Dim intVBAnswer As Integer
'Request whether the user wants to create a separate document
for each record.
intVBAnswer = MsgBox("Do you want to create a separate document
for each record?", vbYesNo, "Merge to Document")
If intVBAnswer = vbYes Then
'Check type of main document
If Doc.MailMerge.MainDocumentType <> wdFormLetters Then
MsgBox "Your Mail Merge Main Document is not of the
correct type." & vbCr & "It must be a Mail Merge Formletter type document."
Exit Sub
End If

The last four lines of which check to see if the mail merge main document is
of the Form Letter type and the rest of the code only runs if it is. As
your main document is not of that type, the rest of the code does not run.

You can try commenting out those four lines of code and see what happens. I
have not tried it, so I do not know if it will work.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Divinite

I tried editing the application and re-compiling. The compile went
though, but gave an error when I tried to run it. I also commented it
out in one of the module sections.

It gets through asking for the file name then comes up with the
following error:
Run-time error '5941': The requested member of the collection does not
exist.

Any ideas?

Thank you!
Jessica
 
D

Doug Robbins - Word MVP

Use File>Open to open the addin and then try again. With the add-in open,
you should be able to press debug when and error occurs and see what line of
code is actually causing the problem.

I suspect however, that the problem is being caused by the fact that the
document produced by executing a Directory type mail merge does not contain
multiple Sections as is the case with a form letter type merge. You may be
able to modify you mail merge main document so that it uses a section break
rather than a page break when it moves to a new set of data, but I really
think that you would be better off using one of the other methods of
splitting the document that are discussed on the website from which you
obtained the Mail Merge to Documents addin.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Divinite

I tried the other options and they didn't work either. No errors, but
no results. Unfortunately, there's no way to do this with section
breaks, they have to be page breaks (and I tried section break, new
page, still doesn't work).

I ended up going back to my longer, but proven method:

Put a mock header1 (white on white text, 2pt font) in with the title
of the document to be saved
Make other headers non-"Header1" styles
Merge to a new document
Open outline view, show only Header1
Split out document
Use Adobe to batch process PDFs from split documents

Not pretty or easy or fast, but it works.

Thanks for trying!
 
D

Doug Robbins - Word MVP

Here's a macro that will split a document by pages:

Sub splitter()

'

' splitter Macro

' Macro created 16-08-98 by Doug Robbins to save each page of a document

' as a separate file with the name Page#.DOC

'

Dim Counter As Long, Source As Document, Target As Document

Set Source = ActiveDocument

Selection.HomeKey Unit:=wdStory

Pages = Source.BuiltInDocumentProperties(wdPropertyPages)

Counter = 0

While Counter < Pages

Counter = Counter + 1

DocName = "Page" & Format(Counter)

Source.Bookmarks("\Page").Range.Cut

Set Target = Documents.Add

Target.Range.Paste

Target.SaveAs FileName:=DocName

Target.Close

Wend

End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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

Top