Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto extract sections?

Status
Not open for further replies.

CeeDee666

Programmer
Joined
Jan 1, 2002
Messages
4
Location
DE
Hi all,

I'm trying to extract certain paragraphs of a word document and put each of them into a separate file. The problem I have is that I only what to extract paragraphs at the second outline level.
I tried to modify several scripts I found on the web to perform this task but didn't succeed.

Does anyone here have an idea how to do something like this in VB? Could you provide me with al link or a code snipplet?

Thanks
Christian
 
Code:
Sub GetLevel2()
Dim r As Range
Dim ThisDoc As Document
Dim aPara As Paragraph

Set ThisDoc = ActiveDocument

For Each aPara In ThisDoc.Paragraphs
    If aPara.OutlineLevel = wdOutlineLevel2 Then
        Set r = aPara.Range
        r.Copy
        Documents.Add
        Selection.Paste
' // need to add your file saving stuff here
' // for each file
        ThisDoc.Activate
        Set r = Nothing
    End If
Next
End Sub

Gerry
 
Oh, and your subject line is incorrect. Unless of course you really ARE asking about sections. Outline levels are not sections.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top