Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #12  
Old 10-14-2015, 05:04 AM
macropod's Avatar
macropod macropod is offline Put last word of line at the new line if the length of the word is x Windows 7 64bit Put last word of line at the new line if the length of the word is x 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

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Za-z]{1,7}>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If .End = ActiveDocument.Range.End Then Exit Sub
    If .Words.Last.Next.Information(wdVerticalPositionRelativeToPage) > _
      .Information(wdVerticalPositionRelativeToPage) Then .InsertBefore Chr(11)
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Put last word of line at the new line if the length of the word is x macro to add brackets to each line and add single quotes to each word in the line bracketandquotes Word VBA 17 02-16-2015 03:51 PM
Word not 'rounding' letters up to word in next line (parents and orphans) Asa Word 4 09-13-2014 06:47 PM
Put last word of line at the new line if the length of the word is x Program to read Email subject line word by word john23# Outlook 1 02-14-2014 10:21 PM
Can you prevent an empty line from appearing in the first line of a page? New Daddy Word 10 11-18-2013 07:01 AM
Put last word of line at the new line if the length of the word is x Outlook 2010 Web Access Subject line length Emerogork Outlook 4 06-08-2011 05:50 PM

Other Forums: Access Forums

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