Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-07-2018, 03:56 PM
macropod's Avatar
macropod macropod is offline Splitting word doc into batches of 1000 words Windows 7 64bit Splitting word doc into batches of 1000 words Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,513
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try something along the lines of:
Code:
Sub Splitter()
Dim DocSrc As Document, DocTgt As Document, i As Long, j As Long, Rng As Range, StrTgt As String
Set DocSrc = ActiveDocument
With DocSrc
  Set Rng = .Range(0, 0): j = 1000: StrTgt = Split(.FullName, ".doc")(0) & "_"
  For i = 1 To -Int(-.ComputeStatistics(wdStatisticWords) / j) 
    If .Range(Rng.Start, .Range.End).ComputeStatistics(wdStatisticWords) < j Then _
      j = .Range(Rng.Start, .Range.End).ComputeStatistics(wdStatisticWords)
      If j = 0 Then Exit For
    With Rng
      .MoveEnd wdWord, j
      .End = .Paragraphs.Last.Range.End
      Do While .ComputeStatistics(wdStatisticWords) < j
        .MoveEnd wdParagraph, wdForward
      Loop
      Set DocTgt = Documents.Add(Template:=DocSrc.AttachedTemplate.FullName, Visible:=False)
      With DocTgt
        .Range.FormattedText = Rng.FormattedText
        .SaveAs2 StrTgt & i & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
        .Close False
      End With
      .Collapse wdCollapseEnd
      If .End = DocSrc.Range.End Then Exit For
    End With
  Next
End With
End Sub
The macro outputs each split to a new document, with the split occurring at the end of whichever paragraph has the 1000th word in the current block.

Any document you run the code on will be split into ~1000 word segments. It's a once-off exercise, though and, if you need to make further splits, re-running the macro will simply regenerate the previous splits (subject to any edits you've made there).

For PC macro installation & usage instructions, see: Installing Macros
For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find (highlight) two and more words in a list of 75k single words in Word 2010 Usora Word 8 05-29-2018 03:34 AM
Splitting word doc into batches of 1000 words Problem with words splitting into 2 lines sharkrfish Word 2 05-21-2015 04:47 PM
Redirect mail in batches in Office for MAC 2011 mervalong Outlook 0 11-08-2011 12:17 AM
Splitting word doc into batches of 1000 words Help Splitting and images in word 2007. aligahk06 Drawing and Graphics 1 10-08-2009 12:58 AM
Splitting word doc into batches of 1000 words WORD 2003 Need help splitting a HUGE Document dlawson Word 4 04-14-2009 12:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:36 AM.


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