|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub DividingBySection()
Dim asection As Section
Dim folderPath As String
Dim fileName As String
Dim sectionCount As Integer
Dim k As Integer
Set doc = ActiveDocument
folderPath = ActiveDocument.Path
sectionCount = doc.Sections.Count
For k = 1 To sectionCount - 1
Set asection = doc.Sections(k)
asection.Range.Select
Selection.Copy
Set newdoc = Documents.Add
newdoc.Content.Paste
ys = k Mod 2
If ys <> 0 Then
fileName = Trim(asection.Range.Paragraphs(1).Range)
fileName = Left(fileName, Len(fileName) - 1)
Else
fileName = fileName & "桥梁资料卡"
End If
newdoc.SaveAs folderPath & "\" & fileName & ".docx"
newdoc.Close True
Next k
End Sub
|
|