Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 07-13-2018, 06:56 PM
PakNotaris PakNotaris is offline Splitting word doc into batches of 1000 words Mac OS X Splitting word doc into batches of 1000 words Office 2016 for Mac
Novice
Splitting word doc into batches of 1000 words
 
Join Date: Jul 2018
Posts: 12
PakNotaris is on a distinguished road
Default


Hi Paul,
That is exactly what I mean: could the macro work in such as way so as to split the doc into 1,000-word chunks separating these by a page break?

Thank you so much again. And my apologies for not having made this clear from the outset.
Reply With Quote
  #17  
Old 07-13-2018, 07:16 PM
Guessed's Avatar
Guessed Guessed is offline Splitting word doc into batches of 1000 words Windows 10 Splitting word doc into batches of 1000 words Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If you want to simply tag a single document with every 100th word then I would just use Highlighting to make it obvious where these are. A macro method to add the highlights should probably firstly remove any existing highlights but that might not be what you want.
Code:
Sub TagEvery1000thWord()
  Dim lWord As Long
  ActiveDocument.Range.HighlightColorIndex = wdNoHighlight
  For lWord = 1000 To ActiveDocument.Words.Count Step 1000
    ActiveDocument.Words(lWord).HighlightColorIndex = wdPink
  Next lWord
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #18  
Old 07-13-2018, 07:25 PM
PakNotaris PakNotaris is offline Splitting word doc into batches of 1000 words Mac OS X Splitting word doc into batches of 1000 words Office 2016 for Mac
Novice
Splitting word doc into batches of 1000 words
 
Join Date: Jul 2018
Posts: 12
PakNotaris is on a distinguished road
Default

Great, thank you! It works But why would it split the doc into approximately 850-word sections not 1,000? Odd, isn't it?

Thank you again. I do appreciate your help with this
Reply With Quote
  #19  
Old 07-13-2018, 07:44 PM
Guessed's Avatar
Guessed Guessed is offline Splitting word doc into batches of 1000 words Windows 10 Splitting word doc into batches of 1000 words Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

ActiveDocument.words has a twisted idea on what a Word is. It includes paragraph marks for instance.

We would need to go back to ComputeStatistics to resolve that. I'll have another look at the code
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #20  
Old 07-13-2018, 07:46 PM
PakNotaris PakNotaris is offline Splitting word doc into batches of 1000 words Mac OS X Splitting word doc into batches of 1000 words Office 2016 for Mac
Novice
Splitting word doc into batches of 1000 words
 
Join Date: Jul 2018
Posts: 12
PakNotaris is on a distinguished road
Default

Aha! Thank you, Andrew. Have a lovely weekend.
Best wishes,
Alex
Reply With Quote
  #21  
Old 07-13-2018, 08:02 PM
Guessed's Avatar
Guessed Guessed is offline Splitting word doc into batches of 1000 words Windows 10 Splitting word doc into batches of 1000 words Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This version will highlight each paragraph that contains a 1,000th word. It is more accurate on what it thinks a Word is.
Code:
Sub TagEvery1000thWordParagraph()
  Dim DocSrc As Document, lCount As Long, lDocLength As Long, aRng As Range
  Set DocSrc = ActiveDocument
  DocSrc.Range.HighlightColorIndex = wdNoHighlight
  lDocLength = DocSrc.Range.End - 2
  Set aRng = DocSrc.Paragraphs(1).Range
  Do Until aRng.End > lDocLength
    lCount = lCount + 1000
    Do Until aRng.ComputeStatistics(wdStatisticWords) > lCount Or aRng.End > lDocLength
      aRng.MoveEnd Unit:=wdParagraph, Count:=1
    Loop
    aRng.Paragraphs.Last.Range.HighlightColorIndex = wdRed
  Loop
  aRng.Paragraphs.Last.Range.HighlightColorIndex = wdNoHighlight  'remove the last para highlight
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #22  
Old 07-13-2018, 08:02 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: 21,963
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

And, for my part:
Code:
Sub Segmenter()
Application.ScreenUpdating = False
Dim i As Long, j As Long, Rng As Range
With ActiveDocument
  Set Rng = .Range(0, 0): j = 1000
  For i = 1 To -Int(-.ComputeStatistics(wdStatisticWords) / j)
    If .Range(Rng.Start, .Range.End).ComputeStatistics(wdStatisticWords) < j Then Exit For
    With Rng
      .MoveEnd wdWord, j
      .End = .Paragraphs.Last.Range.End
      If .End = DocSrc.Range.End Then Exit For
      .InsertAfter vbCr
      .Collapse wdCollapseEnd
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #23  
Old 07-13-2018, 09:07 PM
PakNotaris PakNotaris is offline Splitting word doc into batches of 1000 words Mac OS X Splitting word doc into batches of 1000 words Office 2016 for Mac
Novice
Splitting word doc into batches of 1000 words
 
Join Date: Jul 2018
Posts: 12
PakNotaris is on a distinguished road
Default

Thank you both so much. Both macros work really well. You have been of great help

Best wishes,

Alex
Reply With Quote
Reply



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 04:30 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