메인 컨텐츠로 가기

5 페이지 또는 n 페이지마다 Word 문서를 별도의 파일로 분할하는 방법은 무엇입니까?

수백 페이지가 포함 된 큰 Word 문서가있는 경우이 문서를 10 페이지 또는 n 페이지마다 별도의 파일로 분할하려고합니다. 페이지를 하나씩 복사하여 붙여 넣지 않고이 작업을 빠르고 쉽게 해결할 수있는 방법이 있습니까?

VBA 코드를 사용하여 Word 문서를 10 페이지 또는 n 페이지마다 별도의 파일로 분할

놀라운 기능으로 Word 문서를 10 페이지 또는 n 페이지마다 별도의 파일로 분할


VBA 코드를 사용하여 Word 문서를 10 페이지 또는 n 페이지마다 별도의 파일로 분할

큰 문서를 10 페이지 또는 n 페이지마다 별도의 파일로 분할하려면 다음 VBA 코드가 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 누르고 ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 그런 다음 끼워 넣다 > 모듈, 아래 코드를 복사하여 열린 빈 모듈에 붙여 넣습니다.

VBA 코드 : 10 페이지 또는 n 페이지마다 문서를 별도의 파일로 분할합니다.

Sub DocumentSplitter()
    Dim xDoc As Document, xNewDoc As Document
    Dim xSplit As String, xCount As Long, xLast As Long
    Dim xRngSplit As Range, xDocName As String, xFileExt As String
    Dim xRegEx As RegExp
    Dim xPageCount As Integer
    Dim xShell As Object, xFolder As Object, xFolderItem As Object
    Dim xFilePath As String
    On Error Resume Next
    Set xDoc = Application.ActiveDocument
    Set xShell = CreateObject("Shell.Application")
    Set xFolder = xShell.BrowseforFolder(0, "Select a Folder:", 0, 0)
    If TypeName(xFolder) = "Nothing" Then Exit Sub
    Set xFolderItem = xFolder.Self
    xFilePath = xFolderItem.Path & "\"
    Application.ScreenUpdating = False
    Set xNewDoc = Documents.Add(Visible:=False)
    xDoc.Content.WholeStory
    xDoc.Content.Copy
    xNewDoc.Content.PasteAndFormat wdFormatOriginalFormatting
    With xNewDoc
        xPageCount = .ActiveWindow.Panes(1).Pages.Count
L1:     xSplit = InputBox("The document contains " & xPageCount & " pages." & _
                 vbCrLf & vbCrLf & " Please enter the page count you want to split:", "Kutools for Word", xSplit)
        If Len(Trim(xSplit)) = 0 Then Exit Sub
        Set xRegEx = New RegExp
        With xRegEx
            .MultiLine = False
            .Global = True
            .IgnoreCase = True
            .Pattern = "[^0-9]"
        End With
        If xRegEx.Test(xSplit) = True Then
            MsgBox "Please enter the page number:", vbInformation, "Kutools for Word"
            Exit Sub
        End If
        If VBA.Int(xSplit) >= xPageCount Then
            MsgBox "The number is greater than the document number." & vbCrLf & "Please re-enter", vbInformation, "Kutools for Word"
            GoTo L1
        End If
        xDocName = xDoc. Name
        xFileExt = VBA.Right(xDocName, Len(xDocName) - InStrRev(xDocName, ".") + 1)
        xDocName = Left(xDocName, InStrRev(xDocName, ".") - 1) & "_"
        xFilePath = xFilePath & xDocName
        For xCount = 0 To Int(xPageCount / xSplit)
            xPageCount = .ActiveWindow.Panes(1).Pages.Count
            If xPageCount > xSplit Then
                xLast = xSplit
            Else
                xLast = xPageCount
            End If
            Set xRngSplit = .GoTo(What:=wdGoToPage, Name:=xLast)
            Set xRngSplit = xRngSplit.GoTo(What:=wdGoToBookmark, Name:="\page")
            xRngSplit.Start = .Range.Start
            xRngSplit.Cut
            Documents.Add
            Selection.Paste
            ActiveDocument.SaveAs FileName:=xFilePath & xCount + 1 & xFileExt, AddToRecentFiles:=False
            ActiveWindow.Close
        Next xCount
        Set xRngSplit = Nothing
        xNewDoc.Close wdDoNotSaveChanges
        Set xNewDoc = Nothing
    End With
    Application.ScreenUpdating = True
End Sub

3. 위의 코드를 붙여 넣은 후에도 여전히 응용 프로그램 용 Microsoft Visual Basic 창을 클릭하십시오 도구 > 참고자료, 그리고 튀어 나온 참조-프로젝트 대화 상자, 확인 Microsoft VBScript 정규식 5.5 에서 옵션 사용 가능한 참조 목록 상자, 스크린 샷 참조 :

4. 그런 다음 OK 버튼을 누른 다음 F5 이 코드를 실행하는 키와 폴더 찾아보기 대화 상자가 표시되면 분할 파일을 넣을 폴더를 선택하십시오. 스크린 샷을 참조하십시오.

5. 그런 다음 OK 버튼을 클릭하면 분할 할 페이지 수를 입력하라는 또 다른 프롬프트 상자가 나타납니다. 스크린 샷을 참조하십시오.

6. 그런 다음 OK 버튼을 클릭하면 활성 Word 문서가 10 페이지마다 별도의 파일로 분할되었습니다. 지정된 폴더로 이동하여 결과를 볼 수 있습니다.


놀라운 기능으로 Word 문서를 10 페이지 또는 n 페이지마다 별도의 파일로 분할

Word 용 Kutools 강력한 기능이 포함되어 있습니다. 스플릿 이 유틸리티를 사용하면 큰 Word 문서를 Heading1, 페이지 나누기, 섹션 나누기 및 페이지에 따라 여러 개의 개별 파일로 빠르게 분할 할 수 있습니다.

팁 :이것을 적용하려면 스플릿 먼저 기능을 다운로드해야합니다. Word 용 Kutools을 클릭 한 다음 기능을 빠르고 쉽게 적용하십시오.

설치 후 Word 용 Kutools, 다음과 같이하십시오.

1. 딸깍 하는 소리 쿠툴즈 플러스 > 스플릿, 스크린 샷 참조 :

2. 튀어 나온 대화 상자에서 필요에 따라 다음 작업을 설정하십시오. 스크린 샷을 참조하십시오.

3. 설정을 마친 후 OK, 전체 문서가 각 페이지를 기반으로 여러 파일로 분할됩니다. 스크린 샷을 참조하십시오.

지금 Word 및 무료 평가판 용 Kutools를 다운로드하려면 클릭하십시오!

최고의 사무 생산성 도구

Word 용 Kutools - Over로 단어 경험을 향상시키세요 100 놀라운 기능!

🤖 Kutools AI 도우미: AI로 글쓰기를 변화시키세요 - 콘텐츠 생성  /  텍스트 다시 쓰기  /  문서 요약  /  정보 문의 문서 기반, 모두 Word 내에서

📘 문서 숙달: 페이지 분할  /  문서 병합  /  다양한 형식으로 선택 항목 내보내기(PDF/TXT/DOC/HTML...)  /  PDF로 일괄 변환  /  페이지를 이미지로 내보내기  /  한 번에 여러 파일 인쇄...

컨텐츠 편집: 일괄 찾기 및 바꾸기 여러 파일에 걸쳐  /  모든 사진 크기 조정  /  테이블 행과 열 바꾸기  /  표를 텍스트로 변환...

🧹 손쉬운 청소: 쓸어버리다 추가 공간  /  섹션 나누기  /  모든 헤더  /  텍스트 상자  /  하이퍼 링크  / 더 많은 제거 도구를 보려면 다음 페이지를 방문하세요. 그룹 제거...

광고 삽입물: 삽입 천 단위 구분 기호  /  확인란  /  라디오 버튼  /  QR 코드  /  바코드  /  대각선 표  /  방정식 캡션  /  이미지 캡션  /  테이블 캡션  /  여러 장의 사진  / 더 자세히 알아보세요. 그룹 삽입...

🔍 정밀한 선택: 핀포인트 특정 페이지  /  테이블  /  모양  /  제목 단락  / 탐색 기능 향상 배우기 기능 선택...

스타 강화: 어떤 위치로든 빠르게 이동  /  반복되는 텍스트 자동 삽입  /  문서 창 간을 원활하게 전환합니다.  /  11 변환 도구...

👉 이러한 기능을 사용해 보고 싶으신가요? Word 용 Kutools는 다음을 제공합니다. 60 일 무료 사용, 제한 없음! 🚀
 
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
good things. i used it to split with 1 page 1 word document, it was successful except that each document (after split), it has 2 pages in total although 2nd page is always blank. 
This comment was minimized by the moderator on the site
this code gives compile error which shows user define type is not define
This comment was minimized by the moderator on the site
For me, the VBA creates a single document that is a copy of the original and that's it.
This comment was minimized by the moderator on the site
The VBscript code made Word crash. I was trying to split a 32Mb Word file with many pages but it seems Word can't handle it through VBscript.
Thanks anyway
This comment was minimized by the moderator on the site
Hello, Studia,
The VBA code may crash when there is a large document, it is not stable, so I recommend you use our Kutools for Word tool, it has updated, and support to solve this task, you can download it and free trial 30 day.
Please try, thank you!
This comment was minimized by the moderator on the site
VBA Script: Split a document into separate files every 10 or n pages not worked
This comment was minimized by the moderator on the site
Hello, Sergey,
The above code works well in my Word document, which Word version do you use?
And which step went wrong in your operation?
This comment was minimized by the moderator on the site
i have been trying to split a word file of 166 pages and it gives 166 files each with 166 pages?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations