View Single Post
Old 02-20-2010, 07:15 AM   #5
charleski
Wizard
charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1281258
Join Date: Sep 2009
Device: PRS-505
Here's a very simple word macro to select chapters and paste them into a new document. Place the cursor at the start of the first chapter, run it, save the new doc, run again, etc.

It assumes that chapters are properly marked with one paragraph at the start which has the Heading 1 style. You may need to edit it to adapt it to the particular formatting your document uses (if you have problems with that, then you're probably better-off just using cut-and-paste).

Code:
Sub Macro6()
'
' Extract Chapter
'
'
    Selection.MoveRight Unit:=wdSentence, Count:=2, Extend:=wdExtend
    Selection.Extend
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("Heading 1")

    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.ExtendMode = False
    Selection.MoveLeft Unit:=wdSentence, Count:=2, Extend:=wdExtend
    Selection.Copy
    Selection.MoveRight Unit:=wdSentence, Count:=1
    Application.Documents.Add
    Selection.Paste
    
End Sub
charleski is offline   Reply With Quote