Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-09-2021, 12:51 PM
bill1234 bill1234 is offline Create Individual Files from Mail Merge Windows 7 64bit Create Individual Files from Mail Merge Office 2013
Novice
Create Individual Files from Mail Merge
 
Join Date: Jun 2019
Posts: 2
bill1234 is on a distinguished road
Default Create Individual Files from Mail Merge


I have a macro that works for the most part. I have a mail merge file of two page letters, which I want to convert into individual 2 page files. For some reason, I am only getting on page in the new file with the macro. I believe the part causing the issue is under the "Removes the break that is copied at the end of the section, if any.", but I have no idea how to fix it.

Code:
 'Used to set criteria for moving through the document by section.
    Application.Browser.Target = wdBrowseSection
    
    'A mailmerge document ends with a section break next page.
    'Subtracting one from the section count stop error message.
    For i = 1 To ((ActiveDocument.Sections.Count) - 1)

        'Select and copy the section text to the clipboard
        ActiveDocument.Bookmarks("\Section").Range.Copy

        'Create a new document to paste text from clipboard.
        Documents.Add
        Selection.Paste

        'Removes the break that is copied at the end of the section, if any.
        Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.Delete Unit:=wdCharacter, Count:=1

        ChangeFileOpenDirectory filesave
        DocNum = DocNum + 1
        ActiveDocument.SaveAs FileName:=appexcel.sheets("sheet1").Cells(i + 1, 1).Value & " document file name " & Year(Now()) & ".doc"
        ActiveDocument.Close
        'Move the selection to the next section in the document
        Application.Browser.Next
    Next i
    ActiveDocument.Close savechanges:=wdDoNotSaveChanges
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge group by key and split to individual pdf files ales.jamsek Mail Merge 4 01-21-2021 09:27 PM
Create Individual Files from Mail Merge Password protect individual files after merge merkyfitz Mail Merge 4 03-10-2020 03:08 PM
Create Individual Files from Mail Merge Mail merge to individual files, there's any kind of progress indicator eduzs Word VBA 3 08-31-2018 08:46 PM
Can you have Individual Text in a Mail Merge SiberianBreaks21 Mail Merge 1 07-25-2014 05:01 PM
Create Individual Files from Mail Merge Mail Merge To Individual PDF Files iamrickdeans Mail Merge 1 01-15-2014 12:46 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft