Print section by beginning, end phrase

A

achidsey

Word Experts,

I generally work in Excel VBA but there are a few things that I need to do
in text files that I would like to automate with Word VBA.

I receive a document each morning and have to print certain sections of it
which I identify through several character searches. I would like to know
how I can print a section based on the results of a few searches.

My document is similar to the following simplied version:

<Begin Document>>

Account: X435

Daily Positions
IBM 400
MSFT 1000
Daily Positions Total: 1400

Account: X435 (I print from this line...)

Position Values
IBM 32000
MSFT 30000
Net Cap 62000 (to this line)


Account: X435
Commissions
IBM 100
MSFT 250
Commissions 350

<<End Document>>

What I do currently is search for "Net Cap", and then manually select the
section from the "Account: X435" above the "Net Cap" through the line
including "Net Cap" and then print that section.

I know how to code the methods for a search-Down, a search-Up, and to print.

What I don't know how to do is to code:

Select the section between "Net Cap" (the result of the first search)
and the "Account: X435" (result of the second search) above it.

How would I code this?

I think my code would be similar to:

Sub PrintSection()

Search-Down for "Net Cap"
Name it with variable NetCap

Search-Up for "Account: X435"
Name it with variable X435.

Print Section between X435 and NetCap (I don't know how to code
this)

End Sub

Thanks in advance,
Alan
 

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