Μετάβαση στο κύριο περιεχόμενο

Πώς να αποθηκεύσετε κάθε σελίδα ως ξεχωριστά αρχεία pdf σε ένα έγγραφο του Word;

Κατά τη χρήση του εγγράφου Microsoft Word, μπορείτε να αποθηκεύσετε κάθε σελίδα ως ξεχωριστά αρχεία pdf ένα προς ένα με τη ενσωματωμένη λειτουργία Αποθήκευση ως. Ωστόσο, εάν υπάρχουν εκατοντάδες σελίδες πρέπει να χωριστούν και να αποθηκευτούν ως μεμονωμένα αρχεία pdf, πώς μπορείτε να το κάνετε; Αυτό το άρθρο παρέχει μέθοδο για την γρήγορη επίλυση αυτού του προβλήματος.

Αποθηκεύστε κάθε σελίδα ως ξεχωριστά αρχεία pdf μαζικά με κώδικα VBA


Αποθηκεύστε κάθε σελίδα ως ξεχωριστά αρχεία pdf μαζικά με κώδικα VBA

Ο παρακάτω κώδικας VBA σάς βοηθά να αποθηκεύετε γρήγορα κάθε σελίδα σε ένα έγγραφο ως μεμονωμένα αρχεία pdf ταυτόχρονα. Κάντε τα εξής:

1. Ανοίξτε το έγγραφο που θα αποθηκεύσετε κάθε σελίδα ή συγκεκριμένες σελίδες ως αρχεία pdf και, στη συνέχεια, πατήστε το άλλος + F11 για να ανοίξετε το Microsoft Visual Basic για εφαρμογές παράθυρο.

2. Στο Microsoft Visual Basic για εφαρμογές παράθυρο, κάντε κλικ στην επιλογή Κύριο θέμα > Μονάδα μέτρησης, αντιγράψτε κάτω από τον κώδικα VBA στο παράθυρο Module.

Κωδικός VBA: Αποθηκεύστε κάθε σελίδα ως ξεχωριστά αρχεία pdf ταυτόχρονα σε ένα έγγραφο του Word

Sub SaveAsSeparatePDFs()
'Updated by Extendoffice 20180906
    Dim I As Long
    Dim xStr As String
    Dim xPathStr As Variant
    Dim xDictoryStr As String
    Dim xFileDlg As FileDialog
    Dim xStartPage, xEndPage As Long
    Dim xStartPageStr, xEndPageStr As String
    Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xFileDlg.Show <> -1 Then
        MsgBox "Please chose a valid directory", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    xPathStr = xFileDlg.SelectedItems(1)
    xStartPageStr = InputBox("Begin saving PDFs starting with page __? " & vbNewLine & "(ex: 1)", "Kutools for Word")
    xEndPageStr = InputBox("Save PDFs until page __?" & vbNewLine & "(ex: 7)", "Kutools for Word")
    If Not (IsNumeric(xStartPageStr) And IsNumeric(xEndPageStr)) Then
        MsgBox "The enterng start page and end page should be number format", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    xStartPage = CInt(xStartPageStr)
    xEndPage = CInt(xEndPageStr)
    If xStartPage > xEndPage Then
        MsgBox "The start page number can't be larger than end page", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    If xEndPage > ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) Then
        xEndPage = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
    End If
    For I = xStartPage To xEndPage
        ActiveDocument.ExportAsFixedFormat xPathStr & "\Page_" & I & ".pdf", _
        wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportFromTo, I, I, wdExportDocumentWithMarkup, _
        False, False, wdExportCreateHeadingBookmarks, True, False, False
    Next
End Sub

3. Πάτα το F5 κλειδί για την εκτέλεση του κώδικα.

4. Στο Αναζήτηση παράθυρο, επιλέξτε ένα φάκελο για να αποθηκεύσετε τα αρχεία pdf και κάντε κλικ στο OK κουμπί. Δείτε το στιγμιότυπο οθόνης:

5. Στην πρώτη Kutools για το Word πλαίσιο διαλόγου, εισαγάγετε τον αριθμό της αρχικής σελίδας του εγγράφου σας στο πλαίσιο κειμένου και κάντε κλικ στο OK.

6. Στο δεύτερο Kutools για το Word πλαίσιο διαλόγου, εισαγάγετε τον τελευταίο αριθμό σελίδας του εγγράφου σας και, στη συνέχεια, κάντε κλικ στο Εντάξει. Δείτε screenshot:

Note: Εάν θέλετε απλώς να αποθηκεύσετε πολλές συνεχείς σελίδες σε έγγραφο ως ξεχωριστά αρχεία pdf όπως οι σελίδες 4, 5 και 6, εισαγάγετε 4 και 6 ξεχωριστά στα παραπάνω δύο παράθυρα διαλόγου.

Αφού εκτελέσετε τον κώδικα, μεταβείτε στον καθορισμένο φάκελο που επιλέξατε στο βήμα 4, μπορείτε να δείτε ότι όλες οι σελίδες χωρίζονται και αποθηκεύονται ως μεμονωμένα αρχεία pdf όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης.


Διαχωρίστε και αποθηκεύστε κάθε σελίδα ενός εγγράφου ως ξεχωριστά νέα έγγραφα:

Η Διαχωρισμός εγγράφου χρησιμότητα του Kutools για Excel μπορεί να σας βοηθήσει να χωρίσετε και να αποθηκεύσετε εύκολα κάθε σελίδα του τρέχοντος εγγράφου ως ξεχωριστό νέο έγγραφο μαζικά, όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης. Κατεβάστε και δοκιμάστε το τώρα! (60- ημέρα δωρεάν διαδρομή)

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

Kutools για το Word - Βελτιώστε την εμπειρία σας στο Word με το Over 100 Αξιοσημείωτα χαρακτηριστικά!

🤖 Kutools AI Assistant: Μεταμορφώστε το γραπτό σας με AI - Δημιουργία Περιεχομένου  /  Ξαναγράψτε το κείμενο  /  Συνοψίστε τα έγγραφα  /  Ζητήστε πληροφορίες με βάση το Έγγραφο, όλα μέσα στο Word

📘 Κυριαρχία εγγράφων: Διαίρεση σελίδων  /  Συγχώνευση εγγράφων  /  Εξαγωγή επιλογής σε διάφορες μορφές (PDF/TXT/DOC/HTML...)  /  Μαζική μετατροπή σε PDF  /  Εξαγωγή σελίδων ως εικόνες  /  Εκτύπωση πολλών αρχείων ταυτόχρονα...

Επεξεργασία Περιεχομένων: Μαζική εύρεση και αντικατάσταση σε πολλά αρχεία  /  Αλλαγή μεγέθους όλων των εικόνων  /  Μεταφορά σειρών και στηλών πίνακα  /  Μετατροπή πίνακα σε κείμενο...

🧹 Καθαρισμός χωρίς κόπο: Σαρώστε μακριά Επιπλέον χώροι  /  Διακοπές ενότητας  /  Όλες οι κεφαλίδες  /  Κουτιά κειμένου  /  Υπερ-συνδέσεις  / Για περισσότερα εργαλεία αφαίρεσης, κατευθυνθείτε στο δικό μας Κατάργηση ομάδας...

Δημιουργικά ένθετα: Εισάγετε Χιλιάδες Διαχωριστές  /  Πλαίσια ελέγχου  /  Κουμπιά ραδιοφώνου  /  QR Code  /  barcode  /  Διαγώνιος γραμμικός πίνακας  /  Λεζάντα εξίσωσης  /  Λεζάντα εικόνας  /  Λεζάντα πίνακα  /  Πολλαπλές εικόνες  / Ανακαλύψτε περισσότερα στο Εισαγωγή ομάδας...

🔍 Επιλογές Ακρίβειας: Επισήμανση συγκεκριμένες σελίδες  /  πίνακες  /  σχήματα  /  επικεφαλίδες παραγράφους  / Βελτιώστε την πλοήγηση με περισσότερο Επιλέξτε χαρακτηριστικά...

Βελτιώσεις αστεριών: Πλοηγηθείτε γρήγορα σε οποιαδήποτε τοποθεσία  /  αυτόματη εισαγωγή επαναλαμβανόμενου κειμένου  /  εναλλαγή μεταξύ των παραθύρων εγγράφων  /  11 Εργαλεία μετατροπής...

???? Θέλετε να δοκιμάσετε αυτές τις δυνατότητες; Το Kutools για το Word προσφέρει α Δωρεάν δοκιμαστική περίοδο 60, χωρίς περιορισμούς! 🚀
 
Comments (26)
Rated 5 out of 5 · 3 ratings
This comment was minimized by the moderator on the site
How to set output File Name base on footer each page?
This comment was minimized by the moderator on the site
Hello,

I was wondering if there was a way to have it pull the name for the PDF from the word doc. Example: instead of Page_01, have a pull an account number that was the 3rd line down in the word document?
This comment was minimized by the moderator on the site
Hi
what if I need to set specific name for each splited PDF.
This should be taken from WORD text - it is serial korespondece- all pages have same format
Can you advise?
This comment was minimized by the moderator on the site
Hi, how would you save each pdf page as a name that can be found from within each word page being exported?
This comment was minimized by the moderator on the site
Hi, how will change the code for mac os?
This comment was minimized by the moderator on the site
Is there a way to save per 2 pages?

Ex. save page 1/2 in Page_1.pdf
save page 3/4 in Page_2.pdf

Thanks!
This comment was minimized by the moderator on the site
im wondering the same thing! please help!
This comment was minimized by the moderator on the site
Wondering the same
This comment was minimized by the moderator on the site
10x :) this was realy helpful!!!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Thanks for this, this is great. i was wondering if you have a way of naming my pdf files differently per each extract not only Page_1.pdf.

Thanks
This comment was minimized by the moderator on the site
Hi samir,
How would you like to name these pdf files? Please give me an example.
This comment was minimized by the moderator on the site
Like saving each document with a different name, not just Page_1.pdf and so on.
This comment was minimized by the moderator on the site
Hi Camila,
The following VBA code can help you solve the problem.
Note: You need to specify a different name in this line: xFileName = "AA; BB; CC; DD". Here AA, BB and CC are the names for the PDF files.
Please change them to meet your needs. You can add more names and separate them by semicolon. To mention that the number of names specified must match the number of pages you expored. And the PDF files will be named in order of the specified names in the code.
Sub SaveAsSeparatePDFs()
'Updated by Extendoffice 20221223
    Dim xStr As String
    Dim xPathStr As Variant
    Dim xDictoryStr As String
    Dim xFileDlg As FileDialog
    Dim xStartPage, xEndPage As Long
    Dim xStartPageStr, xEndPageStr As String
    Dim xFileName As String
    Dim xNameArr() As String

    xFileName = "AA; BB; CC; DD"  'Specify a name for each page. The number of names specified must match the number of pages you exported.The PDF files will be named in order of the the specified names
    xNameArr = VBA.Split(xFileName, ";")
    Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xFileDlg.Show <> -1 Then
        MsgBox "Please chose a valid directory", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    xPathStr = xFileDlg.SelectedItems(1)
    xStartPageStr = InputBox("Begin saving PDFs starting with page __? " & vbNewLine & "(ex: 1)", "Kutools for Word")
    xEndPageStr = InputBox("Save PDFs until page __?" & vbNewLine & "(ex: 7)", "Kutools for Word")
    If Not (IsNumeric(xStartPageStr) And IsNumeric(xEndPageStr)) Then
        MsgBox "The enterng start page and end page should be number format", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    xStartPage = CInt(xStartPageStr)
    xEndPage = CInt(xEndPageStr)
    If xStartPage > xEndPage Then
        MsgBox "The start page number can't be larger than end page", vbInformation, "Kutools for Word"
        Exit Sub
    End If
    If xEndPage > ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) Then
        xEndPage = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
    End If
    For I = xStartPage To xEndPage
        ActiveDocument.ExportAsFixedFormat xPathStr & "\" & VBA.Trim(xNameArr(I - 1)) & ".pdf", _
        wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportFromTo, I, I, wdExportDocumentWithMarkup, _
        False, False, wdExportCreateHeadingBookmarks, True, False, False
    Next
    Erase xNameArr
End Sub
This comment was minimized by the moderator on the site
Добрый день!
Есть ли возможность сохранить из ворд файла(используя слияние) в пдф файл - Решения собственников на общее собрание.
При этом учитываем, что PDF должен сохраняться так: в 1 файле должно быть несколько листов (1 квартира), по данному модулю страницы сохраняются в пдф, но раздельно
This comment was minimized by the moderator on the site
Hi,
Sorry I don't understand what you mean. You may need to attach a screenshot or a sample file to describe the problem you encountered more clearly.
This comment was minimized by the moderator on the site
Thanks for the script, it has also saved me a lot of work in exporting pages as pdf!
Rated 5 out of 5
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