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


Joined
Jul 5, 2014
Messages
3
Reaction score
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:
 
Ad

Advertisements


Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top