Note: The other languages of the website are Google-translated. Back to English
Logáil isteach  \/ 
x
or
x
Cláraigh  \/ 
x

or

Conas baisc de dhoiciméid Word iolracha a thiontú go comhaid pdf?

Is furasta duit doiciméad Word a thiontú go comhad PDF leis an bhfeidhm Save as function i Word. Ach más mian leat gach doiciméad Word a thiontú i bhfillteán chun comhaid PDF a scaradh ag an am céanna, conas is féidir leat é a bhaint amach? Taispeánfaidh an t-alt seo cód VBA duit chun iliomad doiciméad Word a chomhshó go comhaid pdf i Word.

Baisc doiciméid iolracha Word a thiontú go comhaid pdf le VBA
Baisc doiciméid iolracha Word a thiontú go comhaid pdf le Kutools for Word


Baisc doiciméid iolracha Word a thiontú go comhaid pdf le VBA

Cuidíonn an cód VBA seo a leanas leat gach doiciméad Word i bhfillteán a thiontú go comhaid pdf go tapa. Déan mar a leanas le do thoil.

1. I Word, 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úil, ansin cóipeáil thíos cód VBA isteach i bhfuinneog an Mhodúil.

Cód VBA: Tiontaigh baisc ilcháipéisí Word go comhaid pdf i Word

Sub ConvertWordsToPdfs()
'Updated by Extendoffice 20181123
    Dim xIndex As String
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xNewName As String
    Dim xFileName As String
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1) + "\"
    xFileName = Dir(xFolder & "*.*", vbNormal)
    While xFileName <> ""
        If ((Right(xFileName, 4)) <> ".doc" Or Right(xFileName, 4) <> ".docx") Then
            xIndex = InStr(xFileName, ".") + 1
            xNewName = Replace(xFileName, Mid(xFileName, xIndex), "pdf")
            Documents.Open FileName:=xFolder & xFileName, _
                ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
                PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
                WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
                wdOpenFormatAuto, XMLTransform:=""
            ActiveDocument.ExportAsFixedFormat OutputFileName:=xFolder & xNewName, _
                ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
                wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
                Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
                CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
                BitmapMissingFonts:=True, UseISO19005_1:=False
            ActiveDocument.Close
        End If
        xFileName = Dir()
    Wend
End Sub

3. Brúigh an F5 eochair chun an cód a rith.

4. Tagann dialóg Brabhsáil aníos, roghnaigh an fillteán ina bhfuil cáipéisí Word a athróidh tú go comhaid pdf, agus cliceáil ar an OK cnaipe.

Ansin athraítear gach doiciméad Word san fhillteán roghnaithe go comhaid pdf ar leithligh ag an am céanna. Féach an pictiúr:


Baisc doiciméid iolracha Word a thiontú go comhaid pdf le Kutools for Word

Má tá sé deacair cód VBA a láimhseáil, is féidir leat triail a bhaint as an Tiontaigh cáipéisí fóntais de Kutools for Word chun an fhadhb a réiteach.

Kutools for Word : Le níos mó ná 100 breiseán áisiúil Word, saor chun triail a dhéanamh gan aon teorannú i 60 lá.

1. cliceáil Kutools Plus > Doc / Docx. Féach an pictiúr:

2. Sa Tiontaire Formáid Doiciméid fuinneog, ní mór duit a dhéanamh mar a leanas:

2.1) Roghnaigh an fillteán tá cáipéisí a athróidh tú go pdf sa Fillteán comhad foinse alt;
2.2 Roghnaigh Tiontaigh docx go pdf ó na Tiontaigh Formáid liosta anuas;
2.3) De réir réamhshocraithe, déanann an Cosán ceann scríbe mar an gcéanna leis an bhfoinse seiceáiltear bosca. Más mian leat gach comhad pdf tiontaithe a chur san fhillteán céanna, coinnigh an rogha seo roghnaithe;
Más mian leat na comhaid pdf agus na doiciméid foinse a scaradh, ní mór duit na Cosán ceann scríbe mar an gcéanna leis an bhfoinse bosca, agus roghnaigh fillteán nua chun na comhaid pdf a shábháil sa Sábháil bosca;
2.4) Cliceáil ar an Tòisich cnaipe. Féach an pictiúr:

3. Ansin tagann bosca dialóige suas chun a insint duit cé mhéad doiciméad a tiontaíodh go rathúil, cliceáil an OK cnaipe agus dún an Tiontaire Formáid Doiciméid fhuinneog.

Anois athraítear gach doiciméad formáide .docx go comhaid pdf.

Más mian leat triail saor in aisce a bhaint as an bhfóntas seo, téigh chuig íoslódáil saor in aisce na bogearraí ar dtús, agus ansin téigh chun an oibríocht a chur i bhfeidhm de réir na gcéimeanna thuas.



Uirlisí Táirgeachta Focal Molta

 

Kutools For Word - Níos mó ná 100 Gné Ardteist le haghaidh Word, Sábháil Do 50% Am

  • Is féidir oibríochtaí casta agus arís agus arís eile a dhéanamh próiseáil aon-uaire i soicindí.
  • Cuir isteach íomhánna iomadúla thar fhillteáin i ndoiciméad Word ag an am céanna.
  • Cumaisc agus comhcheangail comhaid Word iolracha thar fhillteáin i gceann amháin leis an ord atá uait.
  • Roinn an doiciméad reatha i ndoiciméid ar leithligh de réir ceannteidil, briseadh ailt nó critéir eile.
  • Tiontaigh comhaid idir Doc agus Docx, Docx agus PDF, bailiú uirlisí le haghaidh comhshó agus roghnú coitianta, agus mar sin de ...

Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Chengchi · 1 months ago
    VBA 很棒!!感謝您的分享。
  • To post as a guest, your comment is unpublished.
    K DEG · 2 months ago
    This saved my day, thanks so much!

    I would just like to point out for people using this, if the Word seems to freeze, just wait - it is generating the .pdf files. My Word froze but I opened the folder of the files, and could see that it was indeed generating the .pdf for all files.
  • To post as a guest, your comment is unpublished.
    Garrie · 2 months ago
    If you change
    xFileName = Dir(xFolder & "*.*", vbNormal)
     to 
    xFileName = Dir(xFolder & "*.doc*", vbNormal)
    the macro will not crash when there are non-Word files in the same folder.

  • To post as a guest, your comment is unpublished.
    Garrie · 2 months ago
    If you change
    xIndex = InStr(xFileName, ".") + 1
     to 
    xIndex = InStrRev(xFileName, ".") + 1
    it will search from the end of the string to find the first period. This will avoid problems where the filename contains periods.
  • To post as a guest, your comment is unpublished.
    Jirka · 3 months ago
    Change
     xIndex = InStr(xFileName, ".") + 1


  • To post as a guest, your comment is unpublished.
    San · 10 months ago
    The VBA code is great. Cheers ,ate
  • To post as a guest, your comment is unpublished.
    Doris · 1 years ago
    thanks for vba code , it helps a lot.
  • To post as a guest, your comment is unpublished.
    Eric Smith · 1 years ago
    Hello, Thank you so much for this code. It is working well, however, I get a dialog box after each conversion to save the word doc and I have to save. Can you include code in the macro to make that save and close the file instead of having to close each one?
    • To post as a guest, your comment is unpublished.
      Rebecca · 10 months ago
      if you add "ActiveDocument.Save" right above "ActiveDocument.Close" it will save the document before closing itself so you don't have to always hit the save prompt.
  • To post as a guest, your comment is unpublished.
    9aks92 · 1 years ago
    Hi,

    I get runtime error '424':
    Object required

    image attached.


    Please help.

    Thanks.
  • To post as a guest, your comment is unpublished.
    Akshay · 1 years ago
    Hi,

    I get runtime error '424':
    Object required

    at the below code

    Documents.Open Filename:=xFolder & xFileName, _
    ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
    PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
    WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
    wdOpenFormatAuto, XMLTransform:=""


    wdOpenFormatAuto = 0 it says.

    Please help.

    Thanks.
  • To post as a guest, your comment is unpublished.
    Stefan · 1 years ago
    Hi there,


    is there an easy way to adjust the VBA Code so that the Documents are convertet to .txt-Files?
  • To post as a guest, your comment is unpublished.
    Sammy · 2 years ago
    Is there any way to have the file name taken from the text of the document?
  • To post as a guest, your comment is unpublished.
    Marzio · 2 years ago
    VBA if i try to convert file that contains macros the macro swith to open file and ends without close file.
  • To post as a guest, your comment is unpublished.
    michaelwaung · 2 years ago
    So nice blog, Thanks for sharing this blog. It Has so useful information for users. I liked this information so much.
    Hope you keep sharing such kind of information convert word doc to html