+ Reply to Thread
Results 1 to 27 of 27

Paragraphing from Text

Hybrid View

jomili Paragraphing from Text 10-07-2011, 09:23 AM
snb Re: Paragraphing from Text 10-07-2011, 04:55 PM
jomili Re: Paragraphing from Text 10-07-2011, 05:00 PM
snb Re: Paragraphing from Text 10-08-2011, 09:16 AM
abousetta Re: Paragraphing from Text 10-08-2011, 10:19 AM
  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Paragraphing from Text

    I have some PDF books/stories that weren't formatted well, so that the paragraphs are stacked on top of each other instead of having a line between them. I want to print some of these, and make them as readable as possible.

    If I copy from PDF and paste into Word, or convert from PDF to Word, is there a way to separate each paragraph by putting a line beneath it, separating it from the next? An example is below.

    This is how it looks now:
    It was a dark and stormy night.
    In her attic bedroom Margaret Murry, wrapped in an old patchwork quilt, sat on the foot of her
    bed and watched the trees tossing in the frenzied lashing of the wind. Behind the trees clouds
    scudded frantically across the sky. Every few moments the moon ripped through them, creating
    wraith- like shadows that raced along the ground.
    The house shook.
    Wrapped in her quilt, Meg shook.
    She wasn't usually afraid of weather. —It's not just the weather, she thought. —It's the
    weather on top of everything else. On top of me. On top of Meg Murry doing everything wrong.
    School. School was all wrong. She'd been dropped down to the lowest section in her grade. That
    morning one of her teachers had said crossly, "Really, Meg, I don't understand how a child with
    parents as brilliant as yours are supposed to be can be such a poor student. If you don't manage
    to do a little better you'll have to stay back next year."
    During lunch she'd rough-housed a little to try to make herself feel better, and one of the
    girls said scornfully, "After all, Meg, we aren't grammar-school kids any more. Why do you always
    act like such a baby?"
    And on the way home from school, walking up the road with her arms full of books, one of the
    boys had said something about her "dumb baby brother." At this she'd thrown die books on the side
    of the road and tackled him with every ounce of strength she had, and arrived home with her blouse
    torn and a big bruise under one eye.
    Sandy and Dennys, her ten-year-old twin brothers, who got home from school an hour earlier
    than she did, were disgusted. "Let us do the fighting when it's necessary," they told her.
    —A delinquent, that's what I am, she thought grimly. — That's what they'll be saying next. Not
    Mother. But Them. Everybody Else. I wish Father—
    But it was still not possible to think about her father without the danger of tears. Only her
    mother could talk about him in a natural way, saying, "When your father gets back—"
    Gets back from where? And when? Surely her mother must know what people were saying, must be
    aware of the smugly vicious gossip. Surely it must hurt her as it did Meg. But if it did she gave
    no outward sign. Nothing ruffled the serenity other expression.
    —Why can't I hide it, too? Meg thought. Why do I always have to show everything?
    The window rattled madly in the wind, and she pulled the quilt dose about her. Curled up on
    one of her pillows a gray fluff of kitten yawned, showing its pink tongue, tucked its head under
    again, and went back to sleep.
    This is way I would like it:
    It was a dark and stormy night.
    
    In her attic bedroom Margaret Murry, wrapped in an old patchwork quilt, sat on the foot of her
    bed and watched the trees tossing in the frenzied lashing of the wind. Behind the trees clouds
    scudded frantically across the sky. Every few moments the moon ripped through them, creating
    wraith- like shadows that raced along the ground.
    
    The house shook.
    
    Wrapped in her quilt, Meg shook.
    
    She wasn't usually afraid of weather. —It's not just the weather, she thought. —It's the
    weather on top of everything else. On top of me. On top of Meg Murry doing everything wrong.
    School. School was all wrong. She'd been dropped down to the lowest section in her grade. That
    morning one of her teachers had said crossly, "Really, Meg, I don't understand how a child with
    parents as brilliant as yours are supposed to be can be such a poor student. If you don't manage
    to do a little better you'll have to stay back next year."
    
    During lunch she'd rough-housed a little to try to make herself feel better, and one of the
    girls said scornfully, "After all, Meg, we aren't grammar-school kids any more. Why do you always
    act like such a baby?"
    
    And on the way home from school, walking up the road with her arms full of books, one of the
    boys had said something about her "dumb baby brother." At this she'd thrown die books on the side
    of the road and tackled him with every ounce of strength she had, and arrived home with her blouse
    torn and a big bruise under one eye.
    
    Sandy and Dennys, her ten-year-old twin brothers, who got home from school an hour earlier
    than she did, were disgusted. "Let us do the fighting when it's necessary," they told her.
    —A delinquent, that's what I am, she thought grimly. — That's what they'll be saying next. Not
    Mother. But Them. Everybody Else. I wish Father—
    
    But it was still not possible to think about her father without the danger of tears. Only her
    mother could talk about him in a natural way, saying, "When your father gets back—"
    
    Gets back from where? And when? Surely her mother must know what people were saying, must be
    aware of the smugly vicious gossip. Surely it must hurt her as it did Meg. But if it did she gave
    no outward sign. Nothing ruffled the serenity other expression.
    
    —Why can't I hide it, too? Meg thought. Why do I always have to show everything?
    The window rattled madly in the wind, and she pulled the quilt dose about her. Curled up on
    one of her pillows a gray fluff of kitten yawned, showing its pink tongue, tucked its head under
    again, and went back to sleep.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Paragraphing from Text

    sub snb()
      thisdocument.content=replace(thisdocument.content,vbcr,vbcr & vbcr)
    end Sub
    Last edited by snb; 10-08-2011 at 09:15 AM.



  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Re: Paragraphing from Text

    SNB,

    The code didn't work at first, then I discovered ThisDocument was mispelled. However, even after correcting for that, running the code produced no effect.

    I've attached a sample I'm trying with.
    Attached Files Attached Files
    Last edited by jomili; 10-07-2011 at 05:03 PM.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Paragraphing from Text

    It works here in your file.

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Paragraphing from Text

    Maybe replace thisdocument with activedocument, but this won't give you the result you are looking for. When you convert or import PDFs into Word it assumes that every line in PDF file is a paragraph on its own. Therefore when you run this code, all it will do is create the impression of double-spacing. You can modify the code that snb provided to replace the paragraph marks with a space and then it will all be merged into one paragraph and then manually add in the correct paragraph marks. I don't know of any way to automate this from a PDF file to a Word document.

    Hope this helps.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Re: Paragraphing from Text

    Hmm...

    SNB, I found my problem with your code; I had it in a module in NORMAL. When I moved it to a module for my document, it worked. However, it worked the way Abousetta described, creating the impression of double-spacing, not paragraphing as intended.

    Would there be a way to do it based on line-length? I'm no expert in Word, but isn't there a limit to the number of characters that can exist in a line (determined by font and margins). So, if a line is less than, say, 95% of the max characters, we can assume that's a paragraph end, and plug in a paragraph mark?

    I'm sure I'm not the only person who's run into this problem. If Word can't do it, do you know of a non-Word based approach that might work?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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