|
Sub test()
Dim mySec As Section, i As Long, myDoc As Document, SourceDoc As Document
Set SourceDoc = ActiveDocument
For Each mySec In SourceDoc.Sections
If mySec.PageSetup.SectionStart = wdSectionNewPage And mySec.Index > 1 Then
Set myDoc = Application.Documents.Add
myDoc.Content.FormattedText = SourceDoc.Range(i, mySec.Range.Start - 1)
myDoc.Content.Sections.Last.PageSetup.SectionStart = _
SourceDoc.Range(i, mySec.Range.Start - 1).Sections.Last.PageSetup.SectionStart
i = mySec.Range.Start
End If
If mySec.Index = SourceDoc.Sections.Count Then
Set myDoc = Application.Documents.Add
myDoc.Content.FormattedText = SourceDoc.Range(i, SourceDoc.Content.End)
myDoc.Content.Sections.Last.PageSetup.SectionStart = _
SourceDoc.Range(i, SourceDoc.Content.End).Sections.Last.PageSetup.SectionStart
End If
Next
End Sub
求帮忙的这个可以按照节拆分 但是不能自动保存 求高人改改 保存在打开的文件夹中 谢谢了 |
|