How to write a macro to only keep certain text and paragraphs

Discussion in 'Word VBA' started by DanM, Jul 5, 2014.

  1. DanM

    DanM

    Joined:
    Jul 5, 2014
    Messages:
    3
    Likes Received:
    0
    Hi,

    I could use some help getting started on some macros that I need to write that look through a text file (output from a novel writing app) and only keeps certain lines and paragraphs, based on some criteria.

    The criteria I want to use is:
    1. Keep all lines that start with "Title:"
    2. Keep all paragraphs of text following the line that starts with "Text:" until a line is reached that starts with "Scene"

    I know the basic logic is:
    Look at each line
    If the line starts with "Title:" then keep that line and then
    Look at each line after that and
    If the line starts with "Text:" then:
    Delete that line but keep all other lines until you come to a line that starts with the word "Scene"
    Else
    Delete Line
    EndIf
    Else
    Delete Line
    EndIf

    Note that there are many of parts to this documents, all of which I want to delete. I only want to keep these parts.

    See a small sample of text below

    Can someone help me get the VBA code for something like this started?

    Thanks,

    Dan

    ----Sample Text----


    Lots of random intro text
    More random intro text
    Even more random intro text

    Scene 1
    Title: Introduction
    Act: N/A
    Time: N/A
    Location: N/A
    Plot Type: N/A
    Description: N/A
    Tension: N/A\

    Text: (63 Words)
    The story ofd things to be described later in a way that would only be fun to others not in the current service of the zoo.
    No way to describe what is happening here. It’s all fun until the zebra’s get loose.

    Scene 2
    Title: Acknowledgements
    Act: N/A
    Time: N/A
    Location: N/A
    Plot Type: N/A
    Description: N/A
    Tension: N/A

    Text: (65 Words)
    I'd like to acknowledge my family, gave me the premise for this story. Basically, what would life be like if blah blah blah

    Characters In Scene

    Character: Baba
    Goal:
    Obstacle:

    Character: Bebe
    Goal:
    Obstacle:
     
    DanM, Jul 5, 2014
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mika

    Excel and text paragraphs

    Mika, Jul 15, 2003, in forum: Word VBA
    Replies:
    0
    Views:
    123
  2. ravi venkata
    Replies:
    0
    Views:
    96
    ravi venkata
    Jun 3, 2004
  3. dvdastor@yahoo.com

    Format all paragraphs except List Paragraphs

    dvdastor@yahoo.com, Sep 2, 2005, in forum: Word VBA
    Replies:
    2
    Views:
    219
    Edward Thrashcort
    Sep 2, 2005
  4. Ashwin
    Replies:
    2
    Views:
    187
    Ashwin
    Nov 21, 2006
  5. SirCodesALot
    Replies:
    2
    Views:
    161
    SirCodesALot
    Oct 31, 2007
  6. avkokin
    Replies:
    3
    Views:
    191
    Helmut Weber
    Sep 28, 2008
  7. roberto21
    Replies:
    3
    Views:
    137
    macropod
    Feb 11, 2009
  8. andreas
    Replies:
    7
    Views:
    205
    andreas
    May 29, 2009
Loading...