View Single Post
  #1   Report Post  
bahtea bahtea is offline
Junior Member
 
Posts: 1
Default Help Define Range (Word 2003 VBA)

My document, named BOOK.doc, is divided into different sections,
each section separated by bold numbers, running from 1-150.
To find the numbers I use this:
.Font.Bold = True
.Text = "([0-9]){1,3}"
I want to be able to define a range that will cover all texts between
the first number found (as the starting point) AND the next one found
(as the ending point), that is, the texts in Section 1. And, after that,
copy the defined range to be pasted onto a new document, processed,
saved and closed (this part I can handle). From there, return to the
BOOK document, proceed on to the next section numbers, ie, 2 and 3,
and so on to the end of the document.

I've been at this for a little more than a week. But my code is only patchwork,
copied from this and that source, and thus fails to work as desired. And I'm
ashamed to show my code, pardon me. I, however, visualise the structure
as something like so:

Dim SectionRange
Do While
From Cursor point
Find...1
Set as range.start

Find...2
One character before the no.
Set as range.end

Range.copy

Create a new doc
Edit/process
Save as section no.doc
Close

Selection/range collapse at end

Loop

Help will be very much appreciated.

Last edited by bahtea : September 23rd 10 at 05:36 AM Reason: Added more details