Link to home
Create AccountLog in
Avatar of VBAMailer
VBAMailer

asked on

Write Subdocuments from one large file into multiple files

Hi all,
I have one massive document created from the mail merge function in which I will separate each document with a page break to create a subdocument.  I need to read each subdocument and based on number of pages, append it to a document with similar page count.  So, not able find quite the right portion of the subdocument object to accomplish this, but here is my code, just need to know how to fill in the blank if statements.  I'm sure it's something simple, but just can think of it.

doc.ActiveWindow.View = wdMasterView
    For Each subdoc In doc.Subdocuments
        Set newdoc = subdoc.Open
        'Remove NextPage section breaks
        'originating from mailmerge
        RemoveAllSectionBreaks newdoc
       
        If newdoc.BuiltInDocumentProperties("Number of pages") = 1 Then
            Set printdoc = app.Documents.Open("C:\test1.doc")

            ' What to do here to write out newdoc into printdoc with only one page???
           
        ElseIf newdoc.BuiltInDocumentProperties("Number of pages") = 2 Then
        Set printdoc = app.Documents.Open("C:\test2.doc")

            ' What to do here to write out newdoc into printdoc with 2 pages???

        Else newdoc.BuiltInDocumentProperties("Number of pages") = 3 Then
        Set printdoc = app.Documents.Open("C:\test3.doc")

            ' What to do here to write out newdoc into printdoc 3 pages???
        End If
       
        docCounter = docCounter + 1
    Next subdoc
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of VBAMailer
VBAMailer

ASKER

Thanks, that'll do the trick!