View Single Post
 
Old 06-30-2012, 01:15 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Quote:
Those sentences should not contain more than 500 characters.
Even that makes for incredibly long sentences!

Powerpoint slides should have the least number of words possible to convey the main points of what is being discussed, not reams of text for people to read.

Be that as it may, try:
Code:
Sub TextSplitter()
Dim Rng As Range
Application.ScreenUpdating = False
With ActiveDocument
  Set Rng = .Range(0, 0)
  Do
    With Rng
      On Error GoTo ErrExit
      .MoveEndUntil cset:=vbCr, Count:=wdForward
      If Len(.Text) > 500 Then
        .End = .Start + 500
        .End = .Start + InStrRev(Rng.Text, ".") + 1
        If .Characters.Last.Text <> vbCr Then
          .Characters.Last.Delete
          .InsertAfter vbCr
        End If
      End If
      DoEvents
      .Start = .Paragraphs.Last.Next.Range.Start
    End With
  Loop Until Rng Is Nothing
ErrExit:
End With
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
The above macro looks forward in paragraph blocks. If the paragraph has more than 500 characters, it stops at the 500th character then looks backwards for the last preceding period, following which it ensures the presence of a paragraph break.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote