精品:批量合并和分割word文檔_第1頁
精品:批量合并和分割word文檔_第2頁
精品:批量合并和分割word文檔_第3頁
精品:批量合并和分割word文檔_第4頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、批量合并和分割word文檔如何把一個word多頁文檔拆分為單頁或多頁1、在word里面打開那個需要分割的文檔(假設(shè)它的文件名叫做“原始文檔.doc”);2、鍵入alt+f11打開vba編輯器,選擇菜單“插入-模塊”;3、粘貼下面的代碼:option explicitsub splitpagesasdocuments() dim osrcdoc as document, onewdoc as document dim strsrcname as string, strnewname as string dim orange as range dim nindex as integer dim f

2、so as object set fso = createobject(scripting.filesystemobject) set osrcdoc = activedocument set orange = osrcdoc.content orange.collapse wdcollapsestart orange.select for nindex = 1 to activedocument.content.information(wdnumberofpagesindocument) osrcdoc.bookmarks(page).range.copy osrcdoc.windows(1

3、).activate application.browser.target = wdbrowsepage application.browser.next strsrcname = osrcdoc.fullname strnewname = fso.buildpath(fso.getparentfoldername(strsrcname), _ fso.getbasename(strsrcname) & _ & nindex & . & fso.getextensionname(strsrcname) set onewdoc = documents.add selection.paste on

4、ewdoc.saveas strnewname onewdoc.close false next set onewdoc = nothing set orange = nothing set osrcdoc = nothing set fso = nothing msgbox 結(jié)束!end sub4、鍵入f5運行,看到“完成!”結(jié)束。5、檢查當前文檔所在路徑下是否生成若干名為“原始文檔_n.doc”(n代表其對應(yīng)原始文檔中的第幾頁)的文檔,檢查它們的內(nèi)容是否就對應(yīng)于原始文檔每個頁面的內(nèi)容。不過那個是按單頁拆分的。如果想按照指定頁數(shù)拆分,請使用下面的代碼,其它步驟和原來那個方案相同。option

5、 explicit sub spliteveryfivepagesasdocuments() dim osrcdoc as document, onewdoc as document dim strsrcname as string, strnewname as string dim orange as range dim nindex as integer, nsubindex as integer, ntotalpages as integer, nbound as integer dim fso as object const nsteps = 100 修改這里控制每隔幾頁分割一次 se

6、t fso = createobject(scripting.filesystemobject) set osrcdoc = activedocument set orange = osrcdoc.content ntotalpages = activedocument.content.information(wdnumberofpagesindocument) orange.collapse wdcollapsestart orange.select for nindex = 1 to ntotalpages step nsteps set onewdoc = documents.add i

7、f nindex + nsteps ntotalpages then nbound = ntotalpages else nbound = nindex + nsteps - 1 end if for nsubindex = nindex to nbound osrcdoc.activate osrcdoc.bookmarks(page).range.copy osrcdoc.windows(1).activate application.browser.target = wdbrowsepage application.browser.next onewdoc.activate onewdo

8、c.windows(1).selection.paste next nsubindex strsrcname = osrcdoc.fullname strnewname = fso.buildpath(fso.getparentfoldername(strsrcname), _ fso.getbasename(strsrcname) & _ & (nindex nsteps + 1) & . & fso.getextensionname(strsrcname) onewdoc.saveas strnewname onewdoc.close false next nindex set onewd

9、oc = nothing set orange = nothing set osrcdoc = nothing set fso = nothing msgbox 結(jié)束!end sub批量合并word文檔word當中的插入文件,一次只可以合并59個,將更多地word文檔合并成一個文檔,方法如下:1、新建一個word文檔,命名后保存到和要合并的多篇文檔所在的文件夾里。2、按alt+f11進入宏編輯器。3、雙擊左上角的thisdocument,在右側(cè)的代碼區(qū)粘貼代碼如下:sub 合并文檔()application.screenupdating = falsemypath = activedocume

10、nt.pathmyname = dir(mypath & & *.doc)i = 0do while myname if myname activedocument.name thenset wb = documents.open(mypath & & myname) selection.wholestory selection.copy windows(1).activate selection.endkey unit:=wdline selection.typeparagraph selection.pastei = i + 1wb.close falseend ifmyname = di

11、rloopapplication.screenupdating = trueend sub4、運行,等候幾分鐘,即可完成合并。如何合并多個word文檔把大量 word 文檔合并到一個文檔中,用復(fù)制粘貼太慢了,而用下列方法能快速合并。首先將要合并的多個 word 文檔存放到同一個文件夾中,然后新建一個空白文檔,在菜單中選擇“插入 文件”,在彈出的“插入文件”窗口中選擇上述文件夾,然后用鼠標拖動選擇全部文件(或者使用“ ctrl+a ”快捷鍵),最后單擊“插入”按鈕即可完成所有文檔的合并。word中插入多個word文檔時如何按順序插入word 2003插入word文件,可選用菜單欄中的插入文件,比如選了10個word文檔插入進來了,可是這些文檔是無序的進來,即使事先將這些文檔名字改成1.doc,2.doc,3.doc.也無濟于事,把word屬性的標題等刪了也無用。怎樣才能讓他們

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論