如何将word文档按页码拆分
请参考我回答其它朋友的方案:http://zhidao.baidu.com/question/118581756.html不过那个是按单页拆分的。
如果想按照指定页数拆分,请使用下面的代码,其它步骤和原来那个方案相同。
Option ExplicitSub SplitEveryFivePagesAsDocuments()Dim oSrcDoc As Document, oNewDoc As DocumentDim strSrcName As String, strNewName As StringDim oRange As RangeDim nIndex As Integer, nSubIndex As Integer, nTotalPages As Integer, nBound As IntegerDim fso As ObjectConst nSteps = 200 ' 修改这里控制每隔几页分割一次Set fso = CreateObject("Scripting.FileSystemObject")Set oSrcDoc = ActiveDocumentSet oRange = oSrcDoc.ContentnTotalPages = ActiveDocument.Content.Information(wdNumberOfPagesInDocument)oRange.Collapse wdCollapseStartoRange.SelectFor nIndex = 1 To nTotalPages Step nStepsSet oNewDoc = Documents.AddIf nIndex + nSteps >nTotalPages ThennBound = nTotalPagesElsenBound = nIndex + nSteps - 1End IfFor nSubIndex = nIndex To nBoundoSrcDoc.ActivateoSrcDoc.Bookmarks("\page").Range.CopyoSrcDoc.Windows(1).ActivateApplication.Browser.Target = wdBrowsePageApplication.Browser.NextoNewDoc.ActivateoNewDoc.Windows(1).Selection.PasteNext nSubIndexstrSrcName = oSrcDoc.FullNamestrNewName = fso.BuildPath(fso.GetParentFolderName(strSrcName), _fso.GetBaseName(strSrcName) & "_" & (nIndex \ nSteps + 1) & "." & fso.GetExtensionName(strSrcName))oNewDoc.SaveAs strNewNameoNewDoc.Close FalseNext nIndexSet oNewDoc = NothingSet oRange = NothingSet oSrcDoc = NothingSet fso = NothingMsgBox "结束!"End Sub
请问如何将word按页拆分成N个word文档1
你没说你的Word文件是什么样的,如果word是由图形、图片、表格、文字等各种元素组成的,并且有复杂的格式设置(图表组合、页面设置等等),你若简单地各页复制另存,就会造成版面变化甚至内容丢失。
要想保持各页面中内容和排版不变,你可以在每页的最后插入分节符(也就是在下一页的第一个字符前插入分节符),然后将文件另存为新文件,在新文件中找出要保留的页面,将其余的页都删掉。
重复以上操作以保存每一页文件。
如果文件页数很多,上述方法很繁琐,你可以采用软件转化的方法,简单介绍如下:1、先把word转换为pdf文件;2、用工具把pdf文件按每页拆分成多个独立的PDF文件(有很多工具,如pdfspme_win就很好);3、用转化工具把拆分的pdf文件在转回word文件(有很多工具,如SolidConverterPDF),这样目的就达到了。
至于word与pdf如何转化,方法很多,此处略掉,你可以百度一下。
你要问为什么要转化到pdf再转回来,因为只有转到pdf才能保证你的各个页面排版不会变化,通过这样的方法你可以得到与原始word文件完全一致的单页文件。
当然你也可以借助于office中的虚拟打印机同样可以达到目的。
如何将一个word文档按页分割成多个word文档
1、打开需要拆分的文档2、将需要拆分的章节标题样式选中“标题1”3、选择大纲视图——显示1级标题——点击显示文档4、双击第一章前面的“+”号以显示第一章全部内容,点击创建,将第一章进行拆分5、双击图中所示文本标志。
6、会自动弹出新word窗口,新word文档为全部第一章节内容,点击保存即可。
然后重复上面步骤,将其他章节进行拆分。
怎么将word按页面分割为几个文档
1、在Word里面打开那个需要分割的文档(假设它的文件名叫做“原始文档.doc”);键入ALT+F11打开VBA编辑器,选择菜单“插入-模块”;粘贴下面的代码:Option ExplicitSub SplitPagesAsDocuments()Dim oSrcDoc As Document, oNewDoc As DocumentDim strSrcName As String, strNewName As StringDim oRange As RangeDim nIndex As IntegerDim fso As ObjectSet fso = CreateObject("Scripting.FileSystemObject")Set oSrcDoc = ActiveDocumentSet oRange = oSrcDoc.ContentoRange.Collapse wdCollapseStartoRange.SelectFor nIndex = 1 To ActiveDocument.Content.Information(wdNumberOfPagesInDocument)oSrcDoc.Bookmarks("\page").Range.CopyoSrcDoc.Windows(1).ActivateApplication.Browser.Target = wdBrowsePageApplication.Browser.NextstrSrcName = oSrcDoc.FullNamestrNewName = fso.BuildPath(fso.GetParentFolderName(strSrcName), _fso.GetBaseName(strSrcName) & "_" & nIndex & "." & fso.GetExtensionName(strSrcName))Set oNewDoc = Documents.AddSelection.PasteoNewDoc.SaveAs strNewNameoNewDoc.Close FalseNextSet oNewDoc = NothingSet oRange = NothingSet oSrcDoc = NothingSet fso = NothingMsgBox "结束!"End Sub键入F5运行,看到“完成!”结束。
2、检查当前文档所在路径下是否生成若干名为“原始文档_n.doc”(n代表其对应原始文档中的第几页)的文档,检查它们的内容是否就对应于原始文档每个页面的内容。
如文档中有分节符分解后的文档会出现空白页,如要分解后不出现空白页,需要把文档中的分节符删除。
消除分节符的方法:注意事项分节符若全部替换,要注意替换后文档可能会出现排版混乱,这则需要自己手动排版了。
如何用vba按页数拆分word文档
如果想按照指定页数拆分,请使用下面的代码,其它步骤和原来那个方案相同。
Option ExplicitSub SplitEveryFivePagesAsDocuments()Dim oSrcDoc As Document, oNewDoc As DocumentDim strSrcName As String, strNewName As StringDim oRange As RangeDim nIndex As Integer, nSubIndex As Integer, nTotalPages As Integer, nBound As IntegerDim fso As ObjectConst nSteps = 100 ' 修改这里控制每隔几页分割一次Set fso = CreateObject("Scripting.FileSystemObject")Set oSrcDoc = ActiveDocumentSet oRange = oSrcDoc.ContentnTotalPages = ActiveDocument.Content.Information(wdNumberOfPagesInDocument)oRange.Collapse wdCollapseStartoRange.SelectFor nIndex = 1 To nTotalPages Step nStepsSet oNewDoc = Documents.AddIf nIndex + nSteps > nTotalPages ThennBound = nTotalPagesElsenBound = nIndex + nSteps - 1End IfFor nSubIndex = nIndex To nBoundoSrcDoc.ActivateoSrcDoc.Bookmarks("\page").Range.CopyoSrcDoc.Windows(1).ActivateApplication.Browser.Target = wdBrowsePageApplication.Browser.NextoNewDoc.ActivateoNewDoc.Windows(1).Selection.PasteNext nSubIndexstrSrcName = oSrcDoc.FullNamestrNewName = fso.BuildPath(fso.GetParentFolderName(strSrcName), _fso.GetBaseName(strSrcName) & "_" & (nIndex \ nSteps + 1) & "." & fso.GetExtensionName(strSrcName))oNewDoc.SaveAs strNewNameoNewDoc.Close FalseNext nIndexSet oNewDoc = NothingSet oRange = NothingSet oSrcDoc = NothingSet fso = NothingMsgBox "结束!"End Sub
一个word文档怎么拆分成几个文档
一个word文档拆分成几个文档可以利用word自身的功能直接产生新建文档;所需工具:电脑word文档步骤:1、打开需要拆分的文档,文档里面输入内容。
如图所示:2、以大纲视图显示文档,点击【视图】再点击【大纲视图】如图:3、在需要拆分的地方的标题处,设置“级别”如图4、选中要拆分出来的文档(含带级别的标题)。
将鼠标移动到标题前的空心十字符号上,此时鼠标指针变成十字箭头,点击鼠标即可选定该标题以及其包括的内容。
5、打开文档操作,点击“显示文档”,展开相应文档操作按钮;点击“创建”按钮,创建子文档;6、点击“菜单”按钮,弹出“另存为”对话框,即可生成以“设置了级别的标题”为文件名的子文档;如图
vb按页拆分word文档时出现宏怎么操作
下面是按页拆分word文档的程序,请参考:Option ExplicitDim oWord As Word.ApplicationDim oDoc As Word.DocumentDim oNewDoc As Word.DocumentDim oRange As Word.RangeDim iPageNumber As IntegerDim iCount As IntegerDim strTestDir As StringDim strTestFile As StringPrivate Sub Command1_Click() Command1.Visible = False Dim lCurrentStart As Long Dim lCurrentEnd As Long Dim lDocumentEnd As Long Dim lOutputCount As Long lOutputCount = 0 'Launch Word and make it visible Set oWord = CreateObject("Word.Application") oWord.Visible = True 'Open the test document Set oDoc = oWord.Documents.Open(FileName:="C:\ThreePageDocument.doc") 'Find the beginning end of the document oDoc.Select lCurrentStart = oWord.Selection.Start lCurrentEnd = lCurrentStart lDocumentEnd = oWord.Selection.End 'Move the insertion point to the beginning of the document oWord.Selection.Collapse wdCollapseStart Do While (lCurrentEnd < lDocumentEnd) 'Move the insertion pointer to the bottom of this page oWord.Browser.Target = wdBrowsePage oWord.Browser.Next lCurrentEnd = oWord.Selection.End 'On the last page, the start and end will be the same If (lCurrentStart = lCurrentEnd) Then lCurrentEnd = lDocumentEnd End If 'Capture the Range of the current page Set oRange = oDoc.Range(lCurrentStart, lCurrentEnd) 'Create a new document and copy the range to it Set oNewDoc = oWord.Documents.Add oRange.Copy oNewDoc.Range(0, 0).Paste 'Release the Range so we don't leak references Set oRange = Nothing 'Save the new document and close it oNewDoc.SaveAs FileName:="C:\Result" & lOutputCount & ".doc" ' You can save as another FileFormat. If so, change the ' file extension accordingly. oNewDoc.Close Set oNewDoc = Nothing 'Increment the output counter so we don't overwrite this file later lOutputCount = lOutputCount + 1 'Reset the current start position lCurrentStart = oWord.Selection.End LoopEnd Sub
如何把一个word文档按照标题拆分若干个文档?
1、视图——大纲,切换到大纲视图,选中要拆分的标题及正文(选定的方法是鼠标移到该标题前的空心十字符号,此时鼠标指针变成十字箭头,单击鼠标即可选定该标题包括的内容)2、单击【大纲】工具栏中的【创建子文档】按钮,每个子文档会放在一个虚线框中,并且在虚线框的左上角显示一个子文档图标,子文档之间用分节符隔开。
3、把文件保存下来即可。
Word 在保存主文档的同时,会自动保存创建的子文档,并且以子文档的第一行文本作为文件名。
转载请注明出处51数据库 » 按页拆分word文档
搞笑GIF图片段子每天更新