ไปยังเนื้อหาหลัก

วิธีแยกเอกสาร Word และบันทึกเป็นไฟล์ PDF แยกกัน

ใน Word คุณสามารถบันทึกเอกสารทั้งหมดเป็นไฟล์ PDF ได้ แต่คุณเคยพยายามแยกเอกสารแล้วบันทึกหน้าเป็นไฟล์ PDF แยกกันหรือไม่? ในบทความนี้ฉันจะแนะนำวิธีการแก้ปัญหานี้อย่างรวดเร็ว

แยกเอกสาร Word และบันทึกเป็นไฟล์ PDF แยกกันด้วย VBA

แยกเอกสาร Word เป็นไฟล์แยกตามหน้า/หัวเรื่อง1/ แตกแล้วบันทึกเป็น PDF


แยกเอกสาร Word และบันทึกเป็นไฟล์ PDF แยกกันด้วย VBA

รหัส VBA สามารถช่วยให้คุณแยกเอกสาร Word ทีละหน้าได้โดยตรงจากนั้นบันทึกเป็นไฟล์ PDF แยกกัน

1 กด Alt + F11 คีย์เพื่อเปิดใช้งาน Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2 คลิก สิ่งที่ใส่เข้าไป > โมดูลคัดลอกและวางโค้ดด้านล่างลงในไฟล์ โมดูล หน้าต่าง

VBA: บันทึก Word เป็น PDF แยกกัน

Sub SaveAsSeparatePDFs()
'UpdatebyExtendoffice20181120
    Dim I As Long
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xStart, xEnd As Integer
    On Error GoTo lbl
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1)
    xStart = CInt(InputBox("Start Page", "KuTools for Word"))
    xEnd = CInt(InputBox("End Page:", "KuTools for Word"))
    If xStart <= xEnd Then
        For I = xStart To xEnd
            ActiveDocument.ExportAsFixedFormat OutputFileName:= _
                xFolder & "\Page_" & I & ".pdf", ExportFormat:=wdExportFormatPDF, _
                OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
                wdExportFromTo, From:=I, To:=I, Item:=wdExportDocumentContent, _
                IncludeDocProps:=False, KeepIRM:=False, CreateBookmarks:= _
                wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
                BitmapMissingFonts:=False, UseISO19005_1:=False
        Next
    End If
    Exit Sub
lbl:
    MsgBox "Enter right page number", vbInformation, "KuTools for Word"
End Sub

3 กด F5 ในกล่องโต้ตอบเรียกดูเลือกโฟลเดอร์เพื่อวางไฟล์ PDF
doc แยกบันทึก pdf 1

4 คลิก OKจากนั้นป้อนหมายเลขหน้าที่คุณต้องการแยกจุดเริ่มต้นและจุดสิ้นสุด

doc แยกบันทึก pdf 2 doc แยกบันทึก pdf 3

5 คลิก OK. ตอนนี้หน้าต่างๆได้รับการบันทึกเป็นไฟล์ PDF แยกกัน
doc แยกบันทึก pdf 4


แยกเอกสาร Word เป็นไฟล์แยกตามหน้า/หัวเรื่อง1/ แตกแล้วบันทึกเป็น PDF

ถ้าคุณไม่คุ้นเคยกับโค้ด VBA คุณสามารถลองใช้เครื่องมือ add-in – Kutools สำหรับ Wordมัน แยก คุณลักษณะสามารถช่วยคุณแบ่งเอกสาร Word ออกเป็นหน้าตามตัวแบ่งหน้า หมายเลขหน้า หัวเรื่อง 1 ตัวแบ่งส่วน หน้าที่ n ทุกหน้า และหมายเลขหน้าแบบกำหนดเองที่คุณระบุ จากนั้นใช้ ตัวแปลงรูปแบบเอกสาร เพื่อแปลงเอกสาร Word แยกเป็น PDF

หลังจากการติดตั้ง Kutools for Word โปรดทำดังนี้:(ดาวน์โหลด Kutools for Word ฟรีทันที!)

1. เปิดใช้งานเอกสาร Word ที่คุณต้องการแปลงเป็นแยก คลิก Kutools พลัส > แยก.

2 ใน แยกเอกสาร กล่องโต้ตอบ เลือกกฎการแยกตามที่คุณต้องการในส่วน แยกตาม จากนั้นระบุตำแหน่งบันทึกและคำนำหน้าไฟล์เอกสารแยก คลิก Ok.

ตัว Vortex Indicator ได้ถูกนำเสนอลงในนิตยสาร แยกตาม ส่วนจะมีการแบ่ง 6 ประเภทสำหรับคุณ สำหรับรายละเอียดเพิ่มเติมเกี่ยวกับการแยกทุกประเภท โปรดไปที่ แนะนำคุณสมบัติ.

ตอนนี้เอกสารแยกได้รับการบันทึกในตำแหน่งที่ระบุ

3. หลังจากแยกเอกสารแล้ว ให้คลิก Kutools พลัส > เอกสาร / Docx.

4 ใน ตัวแปลงรูปแบบเอกสาร โต้ตอบเลือก แปลง Docx เป็น PDF ฟอร์ม ตัวแปลงรูปแบบ รายการดรอปดาวน์ คลิกเครื่องหมายบวกเพื่อเพิ่มไฟล์หรือโฟลเดอร์ที่มีเอกสารที่คุณต้องการแปลงเป็น PDF จากนั้นระบุการตั้งค่าอื่นๆ ตามที่คุณต้องการ (โดยค่าเริ่มต้น ระบบจะบันทึกไฟล์ PDF ในโฟลเดอร์ต้นทาง คุณสามารถเปลี่ยนได้ ). คลิก Ok.

ตอนนี้เอกสาร Word ได้รับการแปลงเป็นไฟล์ PDF แล้ว


สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

Kutools สำหรับ Word - ยกระดับประสบการณ์คำศัพท์ของคุณด้วย Over 100 คุณสมบัติเด่น!

🤖 Kutools ผู้ช่วย AI: แปลงโฉมงานเขียนของคุณด้วย AI - สร้างเนื้อหา  /  เขียนข้อความใหม่  /  สรุปเอกสาร  /  สอบถามข้อมูล ขึ้นอยู่กับเอกสารทั้งหมดนี้ภายใน Word

📘 ความเชี่ยวชาญด้านเอกสาร: แยกหน้า  /  ผสานเอกสาร  /  ส่งออกตัวเลือกในรูปแบบต่างๆ (PDF/TXT/DOC/HTML...)  /  แบทช์แปลงเป็น PDF  /  ส่งออกเพจเป็นรูปภาพ  /  พิมพ์หลายไฟล์พร้อมกัน...

การแก้ไขเนื้อหา: ค้นหาแบทช์และแทนที่ ข้ามหลายไฟล์  /  ปรับขนาดรูปภาพทั้งหมด  /  ย้ายแถวและคอลัมน์ของตาราง  /  แปลงตารางเป็นข้อความ...

🧹 ทำความสะอาดได้อย่างง่ายดาย: หลบไป พื้นที่พิเศษ  /  แบ่งส่วน  /  ส่วนหัวทั้งหมด  /  กล่องข้อความ  /  เชื่อมโยงหลายมิติ  / หากต้องการดูเครื่องมือถอดเพิ่มเติม โปรดไปที่ของเรา ลบกลุ่ม...

ส่วนแทรกโฆษณา: แทรก ตัวคั่นหลักพัน  /  กล่องกาเครื่องหมาย  /  ปุ่มวิทยุ  /  คิวอาร์โค้ด  /  บาร์โค้ด  /  ตารางเส้นทแยงมุม  /  คำอธิบายสมการ  /  คำบรรยายภาพ  /  คำบรรยายตาราง  /  รูปภาพหลายภาพ  / ค้นพบเพิ่มเติมใน แทรกกลุ่ม...

🔍 การเลือกที่แม่นยำ: ระบุ หน้าที่เฉพาะเจาะจง  /  ตาราง  /  รูปร่าง  /  หัวเรื่องย่อหน้า  / เสริมการนำทางด้วย ข้อมูลเพิ่มเติม เลือกคุณสมบัติ...

การปรับปรุงดาว: นำทางอย่างรวดเร็วไปยังสถานที่ใด ๆ  /  แทรกข้อความซ้ำอัตโนมัติ  /  สลับระหว่างหน้าต่างเอกสารได้อย่างราบรื่น  /  11 เครื่องมือการแปลง...

???? ต้องการลองใช้คุณสมบัติเหล่านี้หรือไม่? Kutools for Word มีไฟล์ ทดลองใช้ฟรี 60 วันโดยไม่มีข้อจำกัด! 🚀
 
Comments (27)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Very useful. I appreciate the work. Wish we can select how many pages for a split
This comment was minimized by the moderator on the site
Hi, the Split feature already support split specific pages and save as PDF only.
Choose Custom from the drop-down list in Split by section, then type the pasge numbers seperated by commas in the Page textbox, please see screenshot:
https://www.extendoffice.com/images/stories/comments/sun-comment/split-word-1.png?1702630242000
This comment was minimized by the moderator on the site
Kedves Napos!

Mostmár majdnem tökéletes a kód ahhoz, amit szeretnék. A 9. sorból szeretném a fájl nevét venni, de csak a 20. karaktertől.

Ez megoldható lenne?

Nagyon szépen köszönöm.

minimorisz
This comment was minimized by the moderator on the site
Hi, try this vba
Sub SaveAsSeparatePDFs()
'UpdatebyExtendoffice20221122
    Dim I As Long
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xStart, xEnd As Integer
    Dim xName As String
    On Error GoTo lbl
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1)
    xStart = CInt(InputBox("Start Page", "KuTools for Word"))
    xEnd = CInt(InputBox("End Page:", "KuTools for Word"))
    If xStart <= xEnd Then
        For I = xStart To xEnd
            xName = InputBox("Page: " & I, "Enter the name for this page")
            ActiveDocument.ExportAsFixedFormat OutputFileName:= _
                xFolder & "\" & xName & ".pdf", ExportFormat:=wdExportFormatPDF, _
                OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
                wdExportFromTo, From:=I, To:=I, Item:=wdExportDocumentContent, _
                IncludeDocProps:=False, KeepIRM:=False, CreateBookmarks:= _
                wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
                BitmapMissingFonts:=False, UseISO19005_1:=False
        Next
    End If
    Exit Sub
lbl:
    MsgBox "Enter right page number", vbInformation, "KuTools for Word"
End Sub

You will rename the pdf file one by one in the poping dialog while applying the vba.
This comment was minimized by the moderator on the site
Hi Sunny,

any chance you know the code for the file name to be taken from the Third line of the file? or a specific location?

thank you!
This comment was minimized by the moderator on the site
Hi, try this vba
Sub SaveAsSeparatePDFs()

'UpdatebyExtendoffice20221221
    Dim I As Long
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xStart, xEnd As Integer
    Dim xStrName As String
    Dim xPath As String
'    On Error Resume Next

    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1)
    xStart = CInt(InputBox("Start Page", "KuTools for Word"))
    xEnd = CInt(InputBox("End Page:", "KuTools for Word"))
    If xStart <= xEnd Then
        For I = xStart To xEnd
                Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=I
                Selection.GoTo What:=wdGoToLine, Which:=wdGoToNext, Name:=3 - 1
                Selection.Extend
                Selection.EndKey Unit:=wdLine
                Selection.EscapeKey
   
                xStrName = Selection.Range
                xStrName = Replace(xStrName, " ", "")
                xStrName = Replace(xStrName, vbLf, "")
                xStrName = Replace(xStrName, Chr(10), "")
                xStrName = Replace(xStrName, Chr(13), "")
                xStrName = Replace(xStrName, "\", "")
                xStrName = Replace(xStrName, "/", "")
                xStrName = Replace(xStrName, ":", "")
                xStrName = Replace(xStrName, "*", "")
                xStrName = Replace(xStrName, "?", "")
                xStrName = Replace(xStrName, "<", "")
                xStrName = Replace(xStrName, ">", "")
                xStrName = Replace(xStrName, "|", "")
                xStrName = Replace(xStrName, """", "")
                If xStrName = "" Then
                    xStrName = I
                End If
                xPath = xFolder & "\" & xStrName & ".pdf"
                ActiveDocument.ExportAsFixedFormat OutputFileName:=xPath, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportFromTo, From:=I, To:=I, Item:=wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=False, CreateBookmarks:=wdExportCreateHeadingBookmarks, DocStructureTags:=True, BitmapMissingFonts:=False, UseISO19005_1:=False
        Next
    End If
End Sub

If there is empty in the third line, the pdf file will be named with number.
This comment was minimized by the moderator on the site
Kedves Napos!

Ez a kód már majdnem tökéletes, a fájl elnevezéséből még ki kellene valahogyan szedni a Az eszközökért felelős személy neve részt, és akkor csak a dolgozó neve maradna.
Köszönöm szépen!

minimorisz
This comment was minimized by the moderator on the site
Kérnék részlete leírást arról, hogy hogyan tudom elnevezni a létrehozott dokumentumokat egy lépésben, akár VBA-val.
Köszönöm.
This comment was minimized by the moderator on the site
Hi,

This code spilts the mail merge into individual PDF's. But I need to split the first 2 pages as one doc. Means if there are 12 pages I need 6 PDF docs. A set of 2 into one PDF file. Right now this code splits it into 12 individual files. Please advise what should I change in the code.
This comment was minimized by the moderator on the site
Hi, SAROJ, I suggest that using tools in Kutools for Word, steps are the same as my reply for TEILLET
This comment was minimized by the moderator on the site
Bonjour,
Est-il possible de changer le module pour fractionner le fichier word en PDF toutes les 24 pages ?

Merci de votre aide
This comment was minimized by the moderator on the site
Hi, TEILLET, you can apply Kutools for Word's Split Document feature, and choose every n pages in the Split by section, then type 24 into Every n pages textbox, specify other settings, then click Ok, every 24 pages will be seperated as one single document. Then apply You should try Doc/Docx feature of Kutools for Excel, and choose Convert Docx to PDF from Format Convert section, and choose one location to save, click Ok, now every 24 page has been saved as PDF.
We have upgraded the features in Kutools for Word, but this article has not update, so the screenshots are old. We will update the contents soon, you can follow the steps to achieve.


Kutools for Word is free in 60-day, you may find more useful tool. Free Download
This comment was minimized by the moderator on the site
Very helpful and easy to use tip. Saved me a lot of time. Thank you so much.
This comment was minimized by the moderator on the site
Hello,When I click okay, the screen disappears but nothing is saved?Is there another setting I need to enable somewhere?
Also, the save to goes to my One Drive local folder, if that might be an issue?Thanks
This comment was minimized by the moderator on the site
Is there also a possibility to save the files not as Page 1 or Page 2, but with a name based on the content of the page?
This comment was minimized by the moderator on the site
I had able split document, need the guidance if i want to save the document with individual name
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