Skip to main content

Conas gach leathanach a shábháil mar chomhaid pdf ar leithligh i ndoiciméad Word?

Agus doiciméad Microsoft Word á úsáid agat, is féidir leat gach leathanach a shábháil mar chomhaid pdf ar leithligh ceann ar cheann lena fheidhm Save As. Mar sin féin, má tá na céadta leathanach ann is gá iad a roinnt agus a shábháil mar chomhaid pdf aonair, conas is féidir leat a dhéanamh? Soláthraíonn an t-alt seo modh duit chun an fhadhb seo a réiteach go tapa.

Sábháil gach leathanach mar chomhaid pdf ar leithligh ar an mórchóir le cód VBA


Sábháil gach leathanach mar chomhaid pdf ar leithligh ar an mórchóir le cód VBA

Cuidíonn an cód VBA thíos leat gach leathanach i ndoiciméad a shábháil go tapa mar chomhaid pdf aonair ag an am céanna. Déan mar a leanas le do thoil.

1. Oscail an doiciméad sábhálfaidh tú gach leathanach nó leathanaigh shonracha mar chomhaid pdf, ansin brúigh an Eile + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil Ionsáigh > Modúl, cóipeáil faoi bhun chód VBA isteach i bhfuinneog an Mhodúil.

Cód VBA: Sábháil gach leathanach mar chomhaid pdf ar leithligh ag an am céanna i ndoiciméad 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. Brúigh an F5 eochair chun an cód a rith.

4. Sa Brabhsáil fuinneog, roghnaigh fillteán chun na comhaid pdf a shábháil agus cliceáil ar an OK cnaipe. Féach an pictiúr:

5. Sa chéad cheann Kutools le haghaidh Word bosca dialóige, cuir uimhir leathanaigh tosaigh do dhoiciméid isteach sa bhosca téacs agus cliceáil OK.

6. Sa dara ceann Kutools le haghaidh Word bosca dialóige, iontráil uimhir leathanaigh dheiridh do dhoiciméid, ansin cliceáil OK. Féach an pictiúr:

nótaí: Mura dteastaíonn uait ach roinnt leathanaigh go leanúnach i ndoiciméad a shábháil mar chomhaid pdf ar leithligh mar leathanaigh 4, 5 agus 6, cuir 4 agus 6 ar leithligh isteach sa dá bhosca dialóige thuas.

Tar éis duit an cód a rith, téigh chuig an bhfillteán sonraithe a roghnaigh tú i gcéim 4, le do thoil. Feiceann tú go roinntear agus go sábhálfar gach leathanach mar chomhaid pdf aonair mar a thaispeántar thíos.


Roinn agus sábháil gach leathanach de dhoiciméad mar dhoiciméid nua ar leithligh:

An Doiciméad Scoilt fóntais de Kutools le haghaidh Excel in ann cabhrú leat gach leathanach den doiciméad reatha a scoilt agus a shábháil go héasca mar dhoiciméad nua ar leithligh ar an mórchóir mar a thaispeántar an pictiúr thíos. Íoslódáil agus bain triail as anois! (60- rian lae saor in aisce)

Uirlisí Táirgiúlachta Oifige is Fearr

Kutools le haghaidh Word - Elevate Your Word Experience with Over 100 Gnéithe Suntasacha!

🤖 Cúntóir Kutools AI: athraigh do chuid scríbhinn le AI - Gin Ábhar  /  Athscríobh Téacs  /  Déan achoimre ar Dhoiciméid  /  Fiosraigh le haghaidh Faisnéise bunaithe ar Doiciméad, ar fad laistigh de Word

📘 Máistreacht Doiciméad: Leathanaigh Scoilte  /  Cumaisc Doiciméid  /  Roghnú Easpórtála i bhFormáidí Éagsúla (PDF/TXT/DOC/HTML...)  /  Baisc a thiontú go PDF  /  Easpórtáil Leathanaigh mar Íomhánna  /  Priontáil Comhaid Il ag an am céanna...

Eagarthóireacht na nÁbhar: Faigh Baisc agus Ionadaigh thar Chomhaid Il  /  Athraigh Méid Gach Pictiúr  /  Trasnaigh Rónna Tábla agus Colúin  /  Tiontaigh Tábla go Téacs...

🧹 Effortless Glan: Sguab as Spásanna Breise  /  Sosanna Alt  /  Gach Ceanntásca  /  Boscaí Téacs  /  Hipearnasc  / Le haghaidh tuilleadh uirlisí a bhaint, ceann chuig ár Bain Grúpa...

Ionsáigh Cruthaitheach: cuir isteach Míle Deighilteoir  /  Boscaí Seiceála  /  Cnaipí Raidió  /  Cód QR  /  barcode  /  Tábla Líne Trasnánach  /  Fotheideal Cothromóid  /  Fotheideal Íomhá  /  Fotheideal Tábla  /  Pictiúir Il  / Faigh amach níos mó sa Cuir isteach Grúpa...

🔍 Roghanna Beachtais: Pionta leathanaigh ar leith  /  táblaí  /  cruthanna  /  míreanna ceannteideal  / Feabhsaigh an loingseoireacht le níos mó Roghnaigh gnéithe...

Feabhsuithe Réalta: Déan nascleanúint go tapa chuig aon láthair  /  cuir isteach téacs athchleachtach go huathoibríoch  /  scoránaigh gan uaim idir fuinneoga doiciméad  /  11 Uirlisí Tiontaithe...

???? Ar mhaith leat triail a bhaint as na gnéithe seo? Kutools le haghaidh Word cuireann a Triail saor in aisce 60 lá, gan teorainneacha! 🚀
 
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