Skip i'r prif gynnwys

Sut i arbed pob tudalen fel ffeiliau pdf ar wahân mewn dogfen Word?

Wrth ddefnyddio dogfen Microsoft Word, gallwch arbed pob tudalen fel ffeiliau pdf ar wahân fesul un gyda'i swyddogaeth Save As. Fodd bynnag, os oes cannoedd o dudalennau angen eu rhannu a'u cadw fel ffeiliau pdf unigol, sut allwch chi wneud? Mae'r erthygl hon yn darparu dull i chi ddatrys y broblem hon yn gyflym.

Cadwch bob tudalen fel ffeiliau pdf ar wahân mewn swmp gyda chod VBA


Cadwch bob tudalen fel ffeiliau pdf ar wahân mewn swmp gyda chod VBA

Mae'r cod VBA isod yn eich helpu i arbed pob tudalen mewn dogfen yn gyflym fel ffeiliau pdf unigol ar yr un pryd. Gwnewch fel a ganlyn.

1. Agorwch y ddogfen byddwch yn cadw pob tudalen neu dudalennau penodol fel ffeiliau pdf, yna pwyswch y Alt + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwl, copïwch isod god VBA i mewn i ffenestr y Modiwl.

Cod VBA: Cadwch bob tudalen fel ffeiliau pdf ar wahân ar yr un pryd mewn dogfen 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. Gwasgwch y F5 allwedd i redeg y cod.

4. Yn y Pori ffenestr, dewiswch ffolder i gadw'r ffeiliau pdf a chliciwch ar y OK botwm. Gweler y screenshot:

5. Yn y cyntaf Kutools am Word blwch deialog, nodwch rif tudalen cychwyn eich dogfen yn y blwch testun a chlicio OK.

6. Yn yr ail Kutools am Word blwch deialog, nodwch rif tudalen olaf eich dogfen, yna cliciwch OK. Gweler y screenshot:

Nodyn: Os ydych chi am arbed sawl tudalen yn barhaus mewn dogfen fel ffeiliau pdf ar wahân fel tudalennau 4, 5 a 6, nodwch 4 a 6 ar wahân yn y ddau flwch deialog uchod.

Ar ôl rhedeg y cod, ewch i'r ffolder penodedig a ddewisoch yng ngham 4, gallwch weld bod pob tudalen yn cael ei rhannu a'i chadw fel ffeiliau pdf unigol fel y dangosir isod.


Rhannwch ac arbedwch bob tudalen o ddogfen fel dogfennau newydd ar wahân:

Mae adroddiadau Dogfen Hollt cyfleustodau Kutools ar gyfer Excel yn gallu'ch helpu chi i rannu ac arbed pob tudalen o'r ddogfen gyfredol yn hawdd mewn dogfen newydd ar wahân mewn swmp fel y dangosir y llun isod. Dadlwythwch a rhowch gynnig arni nawr! (60- llwybr diwrnod am ddim)

Offer Cynhyrchiant Swyddfa Gorau

Kutools am Word - Dyrchafu Eich Profiad Word gyda Dros 100 Nodweddion Rhyfeddol!

🤖 Cynorthwy-ydd Kutools AI: Trawsnewidiwch eich ysgrifennu gydag AI - Cynhyrchu Cynnwys  /  Ailysgrifennu Testun  /  Crynhoi Dogfennau  /  Ymholwch am Wybodaeth yn seiliedig ar Ddogfen, i gyd o fewn Word

📘 Meistrolaeth Dogfen: Tudalennau Hollti  /  Uno Dogfennau  /  Dewis Allforio mewn Fformatau Amrywiol (PDF/TXT/DOC/HTML...)  /  Trosi swp i PDF  /  Allforio Tudalennau fel Delweddau  /  Argraffu Ffeiliau Lluosog ar unwaith...

Golygu Cynnwys: Swp Dod o Hyd i ac Amnewid ar draws Ffeiliau Lluosog  /  Newid Maint Pob Llun  /  Trawsosod Rhesi Bwrdd a Cholofnau  /  Trosi Tabl i Testun...

🧹 Ymdrech Glân: swap i ffwrdd Mannau Ychwanegol  /  Toriadau Adran  /  Pob Pennawd  /  Blychau Testun  /  hypergysylltiadau  / Am fwy o offer tynnu, ewch i'n Dileu Grŵp...

Mewnosodiadau Creadigol: mewnosod Mil o Wahanwyr  /  Blychau Gwirio  /  Botymau Radio  /  Cod QR  /  Cod Bar  /  Tabl Llinell Lletraws  /  Pennawd Hafaliad  /  Capsiwn Delwedd  /  Pennawd Tabl  /  Lluniau Lluosog  / Darganfod mwy yn y Mewnosod Grŵp...

🔍 Detholiadau Manwl: pinbwynt tudalennau penodol  /  tablau  /  siapiau  /  paragraffau pennawd  / Gwella llywio gyda mwy Dewiswch nodweddion...

Gwelliannau Seren: Llywiwch yn gyflym i unrhyw leoliad  /  auto-mewnosod testun ailadroddus  /  toglo'n ddi-dor rhwng ffenestri dogfennau  /  11 Offer Trosi...

???? Eisiau rhoi cynnig ar y nodweddion hyn? Mae Kutools ar gyfer Word yn cynnig a Treial am ddim 60-dydd, heb unrhyw gyfyngiadau! 🚀
 
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