Quote:
Originally Posted by charleski
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
|
Thx for your macro!!!!
It is really cool, i have also written a similar macro but yours is better than mine. Really thx for your macro.
But i encounter a new problem, actually i am dealing with a document with image in it. Therefore i can't seperate the chapters and save it to txt but need to save as xhtml.
But word seems can't save as xhtml files. I ve tried to save as html but can't import those htm files in ecub.
Are there any ways to save doc as xhtml ?