Preskoči na glavno vsebino

Kako razdeliti dokument na več dokumentov v besedilu?

Če imate ogromen besedilni dokument, ki ga morate razdeliti na več dokumentov, si vzemite nekaj minut, da preberete to vadnico. Ta vadnica vam bo pokazala dva načina za razdelitev dokumenta na več dokumentov.


Dokument Word razdelite na določeno ločilo z VBA

Namesto da bi dokument razdelil na več dokumentov ročno, bo ta metoda uvedla VBA za razdelitev Wordovega dokumenta po določenem ločevalniku v Wordu. Naredite naslednje:

1. Pritisnite Alt + F11 tipke skupaj, da odprete okno Microsoft Visual Basic for Application;

2. Kliknite Vstavi > Moduliin nato pod novo kodo VBA prilepite v novo okno modula, ki se odpre.

VBA: Delite Wordov dokument na več dokumentov

Sub SplitNotes(delim As String, strFilename As String)
Dim doc As Document
Dim arrNotes
Dim I As Long
Dim X As Long
Dim Response As Integer
arrNotes = Split(ActiveDocument.Range, delim)
Response = MsgBox("This will split the document into " & UBound(arrNotes) + 1 & " sections.Do you wish to proceed?", 4)
If Response = 7 Then Exit Sub
For I = LBound(arrNotes) To UBound(arrNotes)
If Trim(arrNotes(I)) <> "" Then
X = X + 1
Set doc = Documents.Add
doc.Range = arrNotes(I)
doc.SaveAs ThisDocument.Path & "\" & strFilename & Format(X, "000")
doc.Close True
End If
Next I
End Sub
Sub test()
'delimiter & filename
SplitNotes "///", "Notes "
End Sub

3. Nato kliknite Run ali pritisnite tipko F5, da uporabite VBA.

4. V pojavnem dokumentu Microsoft Word kliknite gumb Da, da nadaljujete.

Opomba:
(1) Ne pozabite dodati ločila enako kot "///" v podtestu na dokument med posameznim odsekom besedila, ki ga želite ločiti. Prav tako se lahko spremenite "///" na ločila, ki ustrezajo vašim potrebam.
(2) Dokumente lahko spremenite "Opombe" v podtestu, ki ustreza vašim potrebam.
(3) In razdeljeni dokumenti bodo shranjeni na isto mesto z izvirno datoteko.
(4) Na koncu izvirne datoteke vam ni treba dodati ločila, v nasprotnem primeru bo po razdelitvi prazen dokument.

Razdelite Wordov dokument na stran z VBA

Tu je še en VBA, ki vam pomaga hitro razdeliti en Wordov dokument na več strani v Wordu. Naredite naslednje:

1. Pritisnite Alt + F11 tipke skupaj, da odprete okno Microsoft Visual Basic for Application;

2. Kliknite Vstavi > Moduliin nato pod novo kodo VBA prilepite v novo okno modula, ki se odpre.

VBA: Razdeli dokument na več dokumentov po straneh v Wordu

Sub SplitIntoPages()
Dim docMultiple As Document
Dim docSingle As Document
Dim rngPage As Range
Dim iCurrentPage As Integer
Dim iPageCount As Integer
Dim strNewFileName As String
Application.ScreenUpdating = False 'Makes the code run faster and reduces screen _
flicker a bit.
Set docMultiple = ActiveDocument 'Work on the active document _
(the one currently containing the Selection)
Set rngPage = docMultiple.Range 'instantiate the range object
iCurrentPage = 1
'get the document's page count
iPageCount = docMultiple.Content.ComputeStatistics(wdStatisticPages)
Do Until iCurrentPage > iPageCount
If iCurrentPage = iPageCount Then
rngPage.End = ActiveDocument.Range.End 'last page (there won't be a next page)
Else
'Find the beginning of the next page
'Must use the Selection object. The Range.Goto method will not work on a page
Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage + 1
'Set the end of the range to the point between the pages
rngPage.End = Selection.Start
End If
rngPage.Copy 'copy the page into the Windows clipboard
Set docSingle = Documents.Add 'create a new document
docSingle.Range.Paste 'paste the clipboard contents to the new document
'remove any manual page break to prevent a second blank
docSingle.Range.Find.Execute Findtext:="^m", ReplaceWith:=""
'build a new sequentially-numbered file name based on the original multi-paged file name and path
strNewFileName = Replace(docMultiple.FullName, ".doc", "_" & Right$("000" & iCurrentPage, 4) & ".doc")
docSingle.SaveAs strNewFileName 'save the new single-paged document
iCurrentPage = iCurrentPage + 1 'move to the next page
docSingle.Close 'close the new document
rngPage.Collapse wdCollapseEnd 'go to the next page
Loop 'go to the top of the do loop
Application.ScreenUpdating = True 'restore the screen updating
'Destroy the objects.
Set docMultiple = Nothing
Set docSingle = Nothing
Set rngPage = Nothing
End Sub 

3. Nato kliknite Run ali pritisnite F5 tipko za uporabo VBA.

Opomba: Dokumenti za razdelitev bodo shranjeni na isto mesto z izvirno datoteko.


Dokument Word razdelite po naslovu / prelomu strani / odseka / prelomu strani z uporabo Kutools for Word

Če imate nameščen Kutools za Word, ga lahko uporabite Split funkcija za enostavno razdelitev enega dokumenta na več na strani, naslov, prelom odseka ali prelom strani, kot jo potrebujete v Wordu.

Kutools za Word je najboljši dodatek za Word, ki poenostavi vaše delo in izboljša vaše sposobnosti obdelave dokumentov. Preizkusite BREZPLAČNO za 60 dnevi! Pridi zdaj!

1.Kliknite Kutools Plus > Split da omogočite Split lastnost.

2. V začetnem pogovornem oknu na zaslonu lahko naredite naslednje:

(1) Izberite način delitve med Razdeljeno po spustni seznam.
Ta funkcija podpira 6 načinov razdeljevanja: naslov 1, prelomi strani, prelomi odsekov, strani, vsakih n strani in obsegi strani po meri, kot je prikazano spodaj:

(2) Kliknite Brskanje Gumb  določiti ciljna mapa, v katero boste shranili razdeljene dokumente;

(3) Vnesite ključno besedo kot predpono novih imen dokumentov v Predpona dokumenta škatla.

Nasvet:
(1) Če določite razdelitev trenutnega dokumenta z Vsakih n strani, morate določiti številko v Vsakih n strani škatla;

(2) Če določite, da trenutni dokument razdelite po obsegu strani po meri, morate te obsege strani po meri vnesti v vejico v stran na primer v polje vnesite 1, 3-5, 12.

3. kliknite Ok za začetek delitve.

Nato se trenutni dokument razdeli na določen način delitve, novi dokumenti pa bodo v velikem obsegu shranjeni v ciljno mapo.

Brskanje in urejanje več Wordovih dokumentov z zavihki kot Firefox, Chrome, Internet Explore 10!

V Firefoxu / Chromeu / IE si morda že želite ogledati več spletnih strani in med njimi preklapljati tako, da enostavno kliknete ustrezne zavihke. Tukaj Office Tab podpira podobno obdelavo, ki omogoča brskanje po več Wordovih dokumentih v enem Wordovem oknu in enostavno preklapljanje med njimi s klikom na njihove zavihke. Kliknite za popolno brezplačno preskusno različico!
Brskajte po več besednih dokumentih v enem oknu kot Firefox


Sorodni članki:


Najboljša pisarniška orodja za produktivnost

Kutools za Word - Izboljšajte svojo besedno izkušnjo z Over 100 Izjemne lastnosti!

🤖 Kutools AI pomočnik: Preoblikujte svoje pisanje z AI - Ustvarite vsebino  /  Prepiši besedilo  /  Povzemite dokumente  /  Povprašajte za informacije na podlagi dokumenta, vse v Wordu

📘 Obvladovanje dokumentov: Razdeljene strani  /  Spoji dokumente  /  Izvozi izbor v različnih formatih (PDF/TXT/DOC/HTML ...)  /  Paketna pretvorba v PDF  /  Izvozi strani kot slike  /  Natisnite več datotek hkrati...

Urejanje vsebine: Serijsko iskanje in zamenjava čez več datotek  /  Spremeni velikost vseh slik  /  Prenos vrstic in stolpcev tabele  /  Pretvori tabelo v besedilo...

🧹 Čiščenje brez napora: Pometite stran Dodatni prostori  /  Prelomi oddelkov  /  Vse glave  /  Besedilna polja  /  Hiperpovezave  / Za več orodij za odstranjevanje pojdite na naš Odstrani skupino...

Ustvarjalni vložki: Vstavi Tisoč ločila  /  Potrditvena polja  /  Radijske tipke  /  QR koda  /  Črtna koda  /  Tabela z diagonalno črto  /  Naslov enačbe  /  Opis slike  /  Naslov tabele  /  Več slik  / Odkrijte več v Vstavi skupino...

???? Natančne izbire: Natančna točka določene strani  /  mize  /  Oblike  /  odstavki naslova  / Izboljšajte navigacijo z več Izberite funkcije...

Izboljšave zvezdic: Hitra navigacija do katere koli lokacije  /  samodejno vstavljanje ponavljajočega se besedila  /  brez težav preklapljate med okni dokumentov  /  11 Orodja za pretvorbo...

???? Želite preizkusiti te funkcije? Kutools for Word ponuja a 60-dan brezplačni preskus, brez omejitev! 🚀
 
Comments (45)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
VBA: Split Document into Multiple Documents by Page in Word - in this when we run it, outcome comes in portrait layout only. If original doc is in landscape then full data of the original doc does not come in the pages breaked by this vba.. There must be seperate vba for portrait and landscape docs.
This comment was minimized by the moderator on the site
I use the "split"-function of "Kutools For Word 9.00" with "header 1" and it works for 48 documents and then it simply stops without any message, as if it wohl have been finished. But I have 700 "header 1" in a 2000 pages document!
Is it simply too much for the tool or is there any other reason?
This comment was minimized by the moderator on the site
your code add new blank page in every page
This comment was minimized by the moderator on the site
This worked fine up until yesterday with Office365, but now I constantly get a runtime error '4605' stating this command is not available. Sometimes at the first page, sometimes at the 3rd page...I can't make it past 3 pages anymore. It happens with line 28 above...

docSingle.Range.Paste 'paste the clipboard contents to the new document
This comment was minimized by the moderator on the site
I've got this error too - Did you get anywhere with it?


Thanks
This comment was minimized by the moderator on the site
yes...i have to run it on the local hard drive. if i run it on a network file or with RemotePC it. has something to do with the script having to wait too long in between commands and it errors out copy and pasting to the clipboard. hope that helps!!
This comment was minimized by the moderator on the site
I copied the document distribution macro 'Split Word Document By Specified Delimiter With VBA', but in the line of 'sub test', the software reads it as a new macro and there are two macros here.
This comment was minimized by the moderator on the site
The script saves a two pages document, the second is total blank.

How to solve this?
This comment was minimized by the moderator on the site
Hi Jorge,
The VBA script introduced splits document by the separator “///”, and you do not need to add delimiter to the end of the original file, if you do, there will be a blank document after splitting.
This comment was minimized by the moderator on the site
Hi kellytte, Could you please explain a little further? I copy and paste the VBA script under the "Split Word by Document with VBA" from above and after I run the process following the instructions above, I always have to manually delete a 2nd blank page on each of the new documents that were created. Are you saying there is something that needs to be removed from the VBA script that will cause this to stop?
This comment was minimized by the moderator on the site
The split works great for me but on page in the merge file turns into 1.5 pages - something with the page layout (+ additional empty page at the end). any ideas how to go around that?
This comment was minimized by the moderator on the site
The Split Word By Document with VBA worked for me, but it is adding a blank page at the end of each document. Is there a way around this?
This comment was minimized by the moderator on the site
I am working on this as well but have not found a way to do it besides manually.
This comment was minimized by the moderator on the site
Does not work at all for me. Goes through the motions but no documents are saved. Maybe because I am using .DOCX files?
This comment was minimized by the moderator on the site
After playing with this code for over an hour I discovered you have to save the document you mail merged then you can run the code on the saved document that has all the pages you need to split up. Hope this helps.
This comment was minimized by the moderator on the site
I always start with a newly-saved document. I found the split documents were actually saved somewhere (I forget; doesn't matter) they were text only - all the formatting had been dropped.
This comment was minimized by the moderator on the site
Maybe something to do with Windows 7 settings? Thoughts from anyone?
This comment was minimized by the moderator on the site
Mais comment garder une mise en page complexe (image de fond, marges, etc) ?
Great but how to keep the lay-out (background image, margins ?)
This comment was minimized by the moderator on the site
Can you split the document based on Heading 1 styles as your "delimiter".
This comment was minimized by the moderator on the site
Hi Andrew,
The VBA script can split the entire document by page. If you need to split by heading 1, we suggest to try Kutools for Word’s Split (Document) feature.
This comment was minimized by the moderator on the site
Downloaded fodler doesnt open at all. Waiting for a long time.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations