|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
请楼主备份原文档后,将原文件放在一个新建文件夹里面,试用下面的宏:
Sub 多页另存()
'将文档每20页保存为一个文档!
'i=20页,p=总页数,j=p/i=保存次数,k=计数器,m=循环变量
On Error Resume Next
Dim i As String, docName As String, p As Long, j As Long, k As Long, m As Long
i = InputBox("请输入要多少页保存为一个文档!", "每N页保存为一个文档", "3")
If i = "" Then Exit Sub
docName = ActiveDocument.Name
docName = Left(docName, Len(docName) - 4)
p = ActiveDocument.Content.Information(wdNumberOfPagesInDocument)
If i = 1 Then
j = p / i
Else
If i >= p Then MsgBox "错误!超出总页数!请重新设定!", vbOKOnly + vbCritical, "信息": End
j = Int(p / i) + 1
End If
For m = 1 To j
k = k + 1
p = ActiveDocument.Content.Information(wdNumberOfPagesInDocument)
If i >= p Then
Selection.WholeStory
Else
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=i + 1, Name:=""
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
End If
Selection.Cut
Documents.Add.Range.Paste
ActiveDocument.SaveAs FileName:=docName & "-" & k & ".doc"
ActiveDocument.Close
ActiveDocument.Characters(1).Copy '变相清空剪贴板
Next m
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub |
评分
-
1
查看全部评分
-
|