Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #21  
Old 05-09-2014, 03:18 AM
macropod's Avatar
macropod macropod is offline How to insert paragraph character after every 500 characters? Windows 7 32bit How to insert paragraph character after every 500 characters? 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

Ah, the joys of trying to adapt code written for one thing to do something else! 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 & "*** " & vbCr
        End If
      End If
      DoEvents
      .Start = .Paragraphs.Last.Next.Range.Start
    End With
  Loop Until Rng Is Nothing
ErrExit:
  With .Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "*** " & vbCr
    .Replacement.Text = "*** "
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
  End With
End With
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
paragraph character



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert paragraph character after every 500 characters? Restricting paragraph styles without restricting character styles Red Pill Word 5 05-25-2012 01:06 PM
character set bobster Word 0 06-07-2011 10:17 AM
How to insert paragraph character after every 500 characters? tab key arrows first character carolinason Word 6 10-30-2010 06:45 PM
Junk characters (box-like characters) in Word file Sashikala Word 1 04-20-2010 02:03 PM
Character style stripped while applying paragraph style sams_gates Word 0 08-29-2009 02:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:57 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