Gå til hovedindhold

Hvordan opdeles dokument i flere dokumenter i ord?

Forfatter: Amanda Li Sidst ændret: 2020-12-23

Hvis du har et massivt orddokument, som du har brug for at opdele i flere dokumenter, skal du tage et par minutter på at læse denne vejledning. Denne vejledning viser dig to metoder til opdeling af et dokument i flere dokumenter.


Opdel Word-dokument ved specificeret afgrænser med VBA

I stedet for at opdele dokument i flere dokumenter manuelt, introducerer denne metode en VBA til at opdele et Word-dokument med den angivne afgrænser i Word. Gør som følger:

1. Trykke Alt + F11 nøgler sammen for at åbne vinduet Microsoft Visual Basic til applikation;

2. Klik indsatte > Moduler, og indsæt derefter under VBA-kode i det nye åbningsmodulvindue.

VBA: Opdel Word-dokument i flere dokumenter af delimiter

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. Klik derefter på Kør eller tryk på F5-tasten for at anvende VBA.

4. Klik på Ja-knappen for at komme videre, når Microsoft Word-dokumentet vises.

Bemærk:
(1) Sørg for at tilføje din afgrænser som den samme som "///" i undertesten til dokumentet mellem hver sektion af tekst, du ønsker at adskille. Du kan også ændre "///" til eventuelle afgrænsere for at imødekomme dit behov.
(2) Du kan ændre dokumenterne "Noter" i underprøven, der passer til dine behov.
(3) Og opdelingsdokumenterne gemmes samme sted med den originale fil.
(4) Du behøver ikke tilføje afgrænser til slutningen af ​​den originale fil. Hvis du gør det, vil der være et tomt dokument efter opdeling.

Opdel Word-dokument efter side med VBA

Her er en anden VBA, der hjælper dig med hurtigt at opdele et Word-dokument til flere efter side i Word. Gør som følger:

1. Trykke Alt + F11 nøgler sammen for at åbne vinduet Microsoft Visual Basic til applikation;

2. Klik indsatte > Moduler, og indsæt derefter under VBA-kode i det nye åbningsmodulvindue.

VBA: Opdel dokument i flere dokumenter efter side i Word

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. Klik derefter på Kør knappen eller tryk på F5 nøgle til at anvende VBA.

Bemærk: Opdelingsdokumenterne gemmes samme sted med den originale fil.


Opdel Word-dokument ved overskrift / side / sektionsskift / sideskift ved hjælp af Kutools til Word

Hvis du har Kutools til Word installeret, kan du anvende det Dele funktion til let at opdele et dokument i flere efter side, overskrift, sektionsskift eller sideskift, som du har brug for i Word ..

Kutools for Word er det ultimative Word-tilføjelsesprogram, der strømliner dit arbejde og øger dine færdigheder i dokumentbehandling. Prøv det GRATIS for 60 dage! Hent den nu!

1.Klik Kutools Plus > Dele at aktivere Dele funktion.

2. I åbningsdialogen på skærmen kan du gøre som følger:

(1) Vælg den splittende måde fra Opdel ved rulleliste.
Denne funktion understøtter 6 opdelingsmåder: overskrift 1, sideskift, sektionsskift, sider, hver n-side og tilpassede sideområder som vist nedenstående skærmbillede:

(2) Klik på Gennemse .  at specificere destinationsmappen, du vil gemme de opdelte dokumenter i;

(3) Indtast et nøgleord som præfikset for nye dokumentnavne i Dokumentpræfiks boks.

tips:
(1) Hvis du angiver opdeling af det aktuelle dokument efter Hver n side, skal du angive nummeret i Hver n side boks;

(2) Hvis du angiver at opdele det aktuelle dokument efter brugerdefinerede sideområder, skal du indtaste disse brugerdefinerede sideområder adskilt af kommaer i Side i feltet, skriv f.eks. 1, 3-5, 12 i feltet.

3. Klik på Ok knap for at starte opdeling.

Derefter opdeles det aktuelle dokument på den angivne opdelings måde, og nye dokumenter gemmes i destinationsmappen i bulk.

Tabbed browsing og redigering af flere Word-dokumenter som Firefox, Chrome, Internet Explore 10!

Du er måske bekendt med at se flere websider i Firefox / Chrome / IE og skifte mellem dem ved let at klikke på tilsvarende faner. Her understøtter Office-fanen lignende behandling, som giver dig mulighed for at gennemse flere Word-dokumenter i et Word-vindue og nemt skifte mellem dem ved at klikke på deres faner. Klik for fuld prøve gratis prøveversion!
Gennemse flere orddokumenter i et vindue som Firefox


Relative artikler:


Bedste kontorproduktivitetsværktøjer

Kutools for Word - Forøg din Word-oplevelse med Over 100 Bemærkelsesværdige funktioner!

🤖 Kutools AI-assistent: Transformer din skrivning med AI - Generer indhold  /  Omskriv tekst  /  Opsummer dokumenter  /  Spørg for information baseret på Dokument, alt sammen i Word

📘 Dokumentbeherskelse: Opdelt sider  /  Flet dokumenter  /  Eksporter udvalg i forskellige formater (PDF/TXT/DOC/HTML...)  /  Batch Konverter til PDF  /  Eksporter sider som billeder  /  Udskriv flere filer på én gang...

Indholdsredigering: Batch Find og erstat på tværs af flere filer  /  Ændr størrelse på alle billeder  /  Transponer tabelrækker og kolonner  /  Konverter tabel til tekst...

🧹 Ubesværet rengøring: Fej væk Ekstra pladser  /  Afsnit bryder  /  Alle overskrifter  /  Tekstbokse  /  Hyperlinks  / For mere fjernelse af værktøjer, gå til Fjern gruppe...

Kreative indlæg: Indsæt Tusind adskillere  /  Afkrydsningsfelter  /  Radio knapper  /  QR kode  /  Stregkode  /  Diagonal linjebord  /  Ligningstekst  /  Billede Caption  /  Tabeltekst  /  Flere billeder  / Oplev mere i Indsæt gruppe...

???? Præcisionsvalg: Find ud af Specifikke sider  /  tabeller  /  Former  /  Overskriftsparagraffer  / Forbedre navigation med mere Vælg funktioner...

Stjerneforbedringer: Naviger til enhver placering  /  Auto-indsæt gentagen tekst  /  Skift mellem dokumentvinduer  /  11 Konverteringsværktøjer...

???? Vil du prøve disse funktioner? Kutools for Word tilbyder en 60-dages gratis prøveperiode, uden begrænsninger! 🚀
 
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