Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-03-2018, 06:10 AM
DavidL DavidL is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows XP Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2007
Novice
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document
 
Join Date: Apr 2018
Posts: 4
DavidL is on a distinguished road
Default Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document

Hi All,
I have text copied from various sources in different word files which I want to format in a particular style so as to match a given layout. Basically the text needs to be broken down into new lines/paragraphs at specific places which is given in the instructions. Instead of having to press 'Enter' and then remove/delete spaces at every line, I wish to do that with just one click per line using macro.
These files could be 500+ in number, so modifying all in one go using Macros is the preferred way.(Although I find it impossible when the point of insertion of 'Enter' can only be done manually on each file.) I have used Macros to achieve 90% of that however need one last step where a Macro can do the following:
1. Where ever the user clicks on the page, all space(regular, non-breaking space, white-space) until the next printed character is deleted.
2. An 'Enter' or Carriage-Return is inserted, so that the text moves to the next line.
Steps 1 and 2 are repeated at every click the user makes on the text.

[Example Text]
offer unto the LORD, have I given thee, and thy sons and thy daughters with thee, by a statute for ever: it is a covenant of salt for ever before the LORD unto thee and to thy seed with thee. 18:20 And the LORD spake unto Aaron, Thou shalt have no inheritance in their land, neither shalt thou have any part among them: I am thy part and thine inheritance among

[Expected Text]
offer unto the LORD, have I given thee,
and thy sons and thy daughters with thee,
by a statute for ever: it is a
covenant of salt for ever before the LORD
unto thee and to thy seed with thee.


18:20 And the LORD spake unto Aaron,
Thou shalt have no inheritance in their
land, neither shalt thou have any
part among them: I am thy
part and thine inheritance among

Notice that as 'Enter' is pressed at the end of these lines although they come in next line but usually a space character is there in front of those lines(appears in MS Word but not here in the forum's text window), which I wanted to remove automatically at one go.
Another approach is to click, delete the required spaces until the next character and then hit enter.
Something like Find ^w and Replace with ^p running at every place a user clicks, but with Macros.
Any help is appreciated.

Thanks,
David Lover
Reply With Quote
  #2  
Old 04-03-2018, 03:08 PM
macropod's Avatar
macropod macropod is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows 7 64bit Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Cross-posted at:
https://stackoverflow.com/questions/...a-word-documen
and:
http://www.vbaexpress.com/forum/show...-Word-document
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-03-2018, 03:09 PM
macropod's Avatar
macropod macropod is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows 7 64bit Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Why not just set the right-indent for the paragraph wherever you want the text to wrap. No code required. Inserting paragraph breaks to achieve the same result makes document maintenance so much harder...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 04-03-2018, 09:20 PM
DavidL DavidL is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows XP Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2007
Novice
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document
 
Join Date: Apr 2018
Posts: 4
DavidL is on a distinguished road
Default

Hi Paul,

Thanks for the reply, setting indent wouldn't work in my case. Here's why.
1. I receive the files in image format with weird font and custom page and margin size with no standard settings..
2. I have to find a way to match my content(the one extracted from internet) to these image files as closely as possible, the minimum being starting word and ending word of a line, so that atleast the content of one line corresponds with the one line in image.
3. Simply applying any of the fixed page, margin, font size doesn't give perfect results. Some or the other words from many lines either remain on the line or move to the next line, not matching with the image files I have.
3. Also, I have no way of contacting the source for the image files to get the fonts, dimensions etc, so have to do it the crude way.

Last edited by DavidL; 04-03-2018 at 09:32 PM. Reason: Replied separately on cross-posting with a quote.
Reply With Quote
  #5  
Old 04-03-2018, 09:23 PM
DavidL DavidL is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows XP Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2007
Novice
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document
 
Join Date: Apr 2018
Posts: 4
DavidL is on a distinguished road
Question

Quote:
Originally Posted by macropod View Post
Just read the page on Cross-Posting.
My sincere apologies, as I wasn't aware of this term, and totally missed the forum-rules about the same, sticking to the basic rules about searching for topics before posting, and maintaining respect and all.
I understand and fully agree with the points presented about cross-posting. In fact, one of my reasons for cross-posting was already listed there; where about a year ago, I posted on a forum and for about 2 weeks there wasn't a reply. I tried contacting the admin not to no avail.

So, what are the expectations from me, regarding cross-posted content. How do I go about responding to other forum articles? What would be ideal?
Reply With Quote
  #6  
Old 04-03-2018, 10:56 PM
DavidL DavidL is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows XP Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2007
Novice
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document
 
Join Date: Apr 2018
Posts: 4
DavidL is on a distinguished road
Default

I got an answer which worked out for me with a minute modification. It's in a different forum, so just linking my answer there.
https://stackoverflow.com/questions/...a-word-documen

Thanks Paul and Sorry if I messed up again.

Last edited by macropod; 04-03-2018 at 11:17 PM. Reason: Corrected link
Reply With Quote
  #7  
Old 04-03-2018, 11:18 PM
macropod's Avatar
macropod macropod is offline Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows 7 64bit Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

As indicated in the link in provided here and at StackOverflow, all that's expected is that you provide links to all forums on which you cross-post the same topic.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 04-04-2018, 12:01 AM
Guessed's Avatar
Guessed Guessed is online now Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Windows 10 Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
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

You could actually set this up to run on a mouse click if you combined that solution with the code provided by Hans at https://social.msdn.microsoft.com/Fo...o?forum=isvvba
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Find and Prompt the user to Replace Lawmuse Word VBA 9 02-27-2023 06:36 AM
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document How to remove trailing & leading spaces in a cell? LearnerExcel Excel Programming 8 02-04-2018 08:22 PM
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Use Word VBA to find, delete and insert duplicate hyperlinks marceepoo Word VBA 2 12-30-2016 09:04 PM
Get rid of leading spaces before paragraphs fig000 Word 11 03-14-2016 01:59 PM
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document Find and replace mutiple spaces between lowercase words only Dave T Word VBA 2 07-16-2015 11:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:23 PM.


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