Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Retrieve Text Under Heading

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Murp - 23 Mar 2006 05:09 GMT
I have a film script in which all the scenes are formatted as Heading 2. I
was wondering if it was possible to use VBA to create a new Word document
that compiles all the text for a number of scenes, e.g. if I want scenes 1, 4
and 7, VBA can find the headings in the document and paste all the associated
text for these headings into a new document?

I must apologise for my vague question - I know VBA from Access, but I have
no idea with Word.
Signature

Yo Yo Ma.

Jezebel - 23 Mar 2006 07:58 GMT
Yes, this is fairly straightforward. I'd suggest something along these
lines ---

1. Set up a UserForm with a listbox for selecting the scenes you want.

2. Populate the listbox by iterating the paragraphs of the document looking
for paragraphs of style 2 (or with Outline level 2). Each time you find one,
add the paragraph text to the list box, and also record (perhaps in a
second, hidden, column in the listbox) the start of the paragraph range
(myPar.Range.Start).

3. For each section the user selects, create a range object, starting with
that heading's Start point, up to the next heading's start minus 1---

set pRange = MyDoc.Range(Start:=MyList.List(pIndex,2),
End:=MyList.List(pIndex + 1,2)-1)

4. Copy that range into a new document.

>I have a film script in which all the scenes are formatted as Heading 2. I
> was wondering if it was possible to use VBA to create a new Word document
[quoted text clipped - 7 lines]
> have
> no idea with Word.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.