Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2024, 06:40 PM
documentimpossible documentimpossible is offline Split a 500 page merge into about 23 documents Windows 10 Split a 500 page merge into about 23 documents Office 2021
Novice
Split a 500 page merge into about 23 documents
 
Join Date: Feb 2024
Posts: 3
documentimpossible is on a distinguished road
Default Split a 500 page merge into about 23 documents


I've read and tested the suggested split but they seem to be designed to split into individual docs, I've got about 500 labels and they're a bit unwieldy as a single document, they'd be best split into each location (roughly 23) which can be determined each time that location field changes, which would also be the file name, is anyone able to help? Thanks

Last edited by documentimpossible; 02-16-2024 at 02:31 AM.
Reply With Quote
  #2  
Old 02-16-2024, 07:41 AM
documentimpossible documentimpossible is offline Split a 500 page merge into about 23 documents Windows 10 Split a 500 page merge into about 23 documents Office 2021
Novice
Split a 500 page merge into about 23 documents
 
Join Date: Feb 2024
Posts: 3
documentimpossible is on a distinguished road
Default

I've just confirmed the addins that say [many to one] don't work for my use case either they seem to be designed to put multiple merge records into a single page or table, I've got a small label entirely filled by it's own data on a table, I want 20 label pages per document
Reply With Quote
  #3  
Old 02-16-2024, 05:13 PM
documentimpossible documentimpossible is offline Split a 500 page merge into about 23 documents Windows 10 Split a 500 page merge into about 23 documents Office 2021
Novice
Split a 500 page merge into about 23 documents
 
Join Date: Feb 2024
Posts: 3
documentimpossible is on a distinguished road
Default

Figured it out for anyone else passing through - thanks to Macropod over at MrExcel - this is his code suggestion with a chunk of my bodge around it to select a range to output on the merge rather than a single

Code:
Sub MergeToSplitLine()


    'Merges one record at a time to the chosen output folder
'Application.ScreenUpdating = False
Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, istart As Long, thisSet As String
Set MainDoc = ActiveDocument
With MainDoc
StrFolder = .Path & "\"

.MailMerge.DataSource.ActiveRecord = 1
thisSet = .MailMerge.DataSource.DataFields("Line").Value
StrName = thisSet & " _ " & .MailMerge.DataSource.DataFields("Part")
istart = 1
'MsgBox "start"

  For i = 1 To .MailMerge.DataSource.RecordCount
    
    
    
    If i < .MailMerge.DataSource.RecordCount Then
    .MailMerge.DataSource.ActiveRecord = i + 1
        If thisSet = .MailMerge.DataSource.DataFields("Line").Value Then
        GoTo skipOutput
        End If
    End If

        With .MailMerge
          .Destination = wdSendToNewDocument
          .SuppressBlankLines = True
          With .DataSource
            .FirstRecord = istart
            .LastRecord = i
          End With
          .Execute Pause:=False
        End With
        With ActiveDocument
          .SaveAs2 FileName:=StrFolder & StrName & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
          .Close SaveChanges:=False
        End With
        If i < .MailMerge.DataSource.RecordCount Then
            istart = i + 1
            .MailMerge.DataSource.ActiveRecord = i + 1
            thisSet = .MailMerge.DataSource.DataFields("Line").Value
            StrName = thisSet & " _ " & .MailMerge.DataSource.DataFields("Part")
        End If
skipOutput:
    
    DoEvents
   
  Next i
End With


Application.ScreenUpdating = True
edit: some issues with getting the last page to end up in the right document especially if it was on it's own
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Split a 500 page merge into about 23 documents Macro to Split Documents Gingerbreadgrl Word VBA 4 09-02-2019 03:18 PM
Split a 500 page merge into about 23 documents Mail Merge - split merged documents and rename each split document based on text in header FuriousD Word VBA 1 05-12-2019 04:06 AM
Help Please: New VBA user trying to use a macro to split Mail Merge documents. Two Run-Time Error zipit189 Word VBA 7 03-18-2015 01:13 PM
Split a 500 page merge into about 23 documents Split each page of mail merge into separate pdf Declan Mail Merge 1 05-28-2014 02:02 AM
Split a 500 page merge into about 23 documents Split multi-page mail merge document, then name file from letter info. BriMan83 Mail Merge 1 04-24-2013 11:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:26 AM.


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