Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2015, 02:03 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default Put last word of line at the new line if the length of the word is x


Hi, I am new in vba and I need to create macro that checks end word of the line and if the length of the word is less than x the word goes to new line. Thanks for all answers.
Reply With Quote
  #2  
Old 10-14-2015, 02:55 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: 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

Please define what you mean by 'line'. Are these lines within a paragraph, or separate paragraphs? Also, when moving a word, this will undoubtedly affect the next line. What do you want to do about that?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-14-2015, 03:11 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

all lines in whole documents...the word should goes to the next line right before words in that line
Reply With Quote
  #4  
Old 10-14-2015, 03:36 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: 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

You haven't answered the questions I asked.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-14-2015, 03:43 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

line hmm row in dokument ?
this is line 1 sdasldnasklndask
this is line 2
Reply With Quote
  #6  
Old 10-14-2015, 03:46 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: 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

Do you not understand the difference between a line within a paragraph and a line that is a paragraph?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 10-14-2015, 03:47 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

No, I dont.
Reply With Quote
  #8  
Old 10-14-2015, 04:35 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: 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

Paragraphs are terminated by paragraph breaks, which appear as ¶ symbols at the end of each paragraph when you toggled Word's formatting display 'on'. Manual line breaks will appear as ↵ at the end of each line.

So:
Quote:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas¶
porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies¶
purus lectus malesuada libero, sit amet commodo magna eros quis¶
urna. Nunc viverra imperdiet enim. Fusce est.¶
is a series of one-line paragraphs

But:
Quote:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies
purus lectus malesuada libero, sit amet commodo magna eros quis
urna. Nunc viverra imperdiet enim. Fusce est.¶
and:
Quote:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas↵
porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies↵
purus lectus malesuada libero, sit amet commodo magna eros quis↵
urna. Nunc viverra imperdiet enim. Fusce est.¶
are both single paragraphs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 10-14-2015, 04:42 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

So the answer would be lines within a paragraph
Reply With Quote
  #10  
Old 10-14-2015, 04:51 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: 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

Which of the two versions I posted?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 10-14-2015, 04:53 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas
porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies
purus lectus malesuada libero, sit amet commodo magna eros quis
urna. Nunc viverra imperdiet enim. Fusce est.¶
Reply With Quote
  #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: 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

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
  #13  
Old 10-14-2015, 05:08 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

in "If .Words.Last.Next.Information(wdVerticalPositionRel ativeToPage) > _" that "_" means ? thx
Reply With Quote
  #14  
Old 10-14-2015, 05:11 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: 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

The _ is a line continuation character.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 10-14-2015, 05:13 AM
2kuku4 2kuku4 is offline Put last word of line at the new line if the length of the word is x Windows 10 Put last word of line at the new line if the length of the word is x Office 2013
Novice
Put last word of line at the new line if the length of the word is x
 
Join Date: Oct 2015
Posts: 9
2kuku4 is on a distinguished road
Default

OK, I am not quite sure which part of code check the length of the last word of the line and where shoud I put my x parameter...
Reply With Quote
Reply



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 12:45 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