+ Reply to Thread
Results 1 to 5 of 5

How to delete line breaks in word using macro

  1. #1
    Registered User
    Join Date
    01-24-2019
    Location
    Chennai
    MS-Off Ver
    2013
    Posts
    96

    How to delete line breaks in word using macro

    Hello,

    I have paragraphs of text in which some texts are partially been cut and moved to next line. Is there any suggestions how to merge it with word macro?

    For example, If we press backspace it will merge with previous line in word right likewise

    FYI, first 5 lines of the word doc should not be altered with this.

  2. #2
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,150

    Re: How to delete line breaks in word using macro

    I guess this is not the correct place of the forum to ask a MS Word question..

    BTW, you dont need a macro for this, you can just use simple Find-Replace method for this....

    - Select the part of the document that you want to make the changes,

    - Activate "Replace" menu,

    -Enter ^p in the "Find what" box, leave empty the "Replace with" box,

    - Hit "Replace All" button.

    .

  3. #3
    Registered User
    Join Date
    01-24-2019
    Location
    Chennai
    MS-Off Ver
    2013
    Posts
    96

    Re: How to delete line breaks in word using macro

    Hi Haluk,

    Its a macro between Excel and word. I need code to automate completely.

    I tried your suggestion problem is it deleted space between paragraph as well and also first five lines?

    It has to delete line breaks between paragraph with first five lines untouched

  4. #4
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483
    Hi priyad,

    I,m answeri g from my phone so I i cannot write the code for yuo.

    The character you mention is called a linefeed..

    In vba you can use vbLF or Chr(13).
    A lineferd is character 13

    Depending on your needs you can use eighter option to find or replace the character as needed..
    Last edited by Roel Jongman; 07-01-2019 at 01:59 PM.

  5. #5
    Registered User
    Join Date
    01-24-2019
    Location
    Chennai
    MS-Off Ver
    2013
    Posts
    96

    Re: How to delete line breaks in word using macro

    Hi Roel,

    Yes, I researched some on line feed and couldn't find better solution yet.

    To be more clear, i'm trying to find text from word and move it to excel using macros. It's almost completed but stuck with these line breaks on very few and causing an error

    Example my text is like below in Word

    173 73079290 ADAPTER AS.-ELBOW 90 DEG (NON ELECTRICAL) (50 NOS)
    | 1068715

    158 84829900 CUP-TAPPERED(69320-BEARING CUP) (1152 NOS) | 12389
    08

    155 84829900 CUP-TAPPERED(69320-BEARING CUP) (866 NOS) | 123890
    8

    I want to be like below for excel run further without any error

    173 73079290 ADAPTER AS.-ELBOW 90 DEG (NON ELECTRICAL) (50 NOS) | 1068715

    158 84829900 CUP-TAPPERED(69320-BEARING CUP) (1152 NOS) | 1238908

    155 84829900 CUP-TAPPERED(69320-BEARING CUP) (866 NOS) | 1238908

    I made sure to delete all white spacing. All I need to take care of line breaks and Need to make sure first five lines of word doc not been affected by any means
    Last edited by priyadharshane; 07-01-2019 at 02:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 03-29-2022, 05:35 AM
  2. Formulas and Line Breaks - inserting mid-string & removing excess breaks
    By MattDay2u in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-24-2017, 09:54 AM
  3. Delete Current Line in word using Excel VBA
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2016, 11:08 AM
  4. Address Concatenate and Line Breaks Failing in Word
    By pdavies1 in forum Excel General
    Replies: 2
    Last Post: 09-22-2015, 10:23 PM
  5. Delete blank line breaks in a cell
    By bushra in forum Excel General
    Replies: 7
    Last Post: 09-24-2013, 12:38 PM
  6. [SOLVED] How do I delete specific word from every line?
    By mrsewer in forum Excel General
    Replies: 5
    Last Post: 09-10-2013, 12:55 AM
  7. Macro to print each row on a seperate page with cell line breaks.
    By sjknight in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2012, 04:22 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1