Consulting

Results 1 to 3 of 3

Thread: Find and Replace/Insert 'CR', del Space where ever a user Clicks in a Word document

  1. #1
    VBAX Newbie
    Joined
    Apr 2018
    Posts
    2
    Location

    Find and Replace/Insert 'CR', del Space where ever 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

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Newbie
    Joined
    Apr 2018
    Posts
    2
    Location
    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
    Last edited by macropod; 04-03-2018 at 11:16 PM. Reason: Corrected link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •