如何将一个WORD文档分割成几个文件?office文档分割成几个文件?
打开要处理的WORD文档,然后ALT+F8调出宏处理窗口,新输入宏名称为MyPg。
点击右侧的编辑按钮,输入如下内容,完成后键盘F5即可。Sub分割WORD()
DimoWordAsWord.ApplicationDimoDocAsWord.Document
DimoNewDocAsWord.DocumentDimoRangeAsWord.RangeDimlCurrentStartAsLongDimlCurrentEndAsLongDimlDocumentEndAsLongDimlOutputCountAsLong
lOutputCount=0
SetoWord=GetObject(,"Word.Application")SetoDoc=ActiveDocument
oDoc.Select
lCurrentStart=oWord.Selection.StartlCurrentEnd=lCurrentStart
lDocumentEnd=oWord.Selection.End
oWord.Selection.CollapsewdCollapseStart
DoWhile(lCurrentEnd oWord.Browser.Next''这行分割几页就复制几次,这里是10页割成一个文件保存
lCurrentEnd=oWord.Selection.End
If(lCurrentStart=lCurrentEnd)ThenlCurrentEnd=lDocumentEndEndIf
SetoRange=oDoc.Range(lCurrentStart,lCurrentEnd)
SetoNewDoc=oWord.Documents.AddoRange.Copy
oNewDoc.Range(0,0).Paste
lOutputCount=lOutputCount+1
oNewDoc.SaveAsFileName:="R:\"&lOutputCount&".doc"''这里更改输出保存盘符,我的是R:盘根目录oNewDoc.Close
lCurrentStart=lCurrentEndLoop
EndSub
|
|