Ana içeriğe atla

Birden çok Word belgesini pdf dosyalarına toplu olarak nasıl dönüştürebilirim?

Word'deki Farklı Kaydet işleviyle bir Word belgesini PDF dosyasına dönüştürmek sizin için kolaydır. Ancak bir klasördeki tüm Word belgelerini aynı anda ayrı PDF dosyalarına dönüştürmek istiyorsanız, bunu nasıl başarabilirsiniz? Bu makale size birden fazla Word belgesini Word'deki pdf dosyalarına toplu olarak dönüştürmek için bir VBA kodu gösterecektir.

VBA ile çoklu Word belgelerini pdf dosyalarına toplu dönüştürün
Kutools for Word ile birden fazla Word belgesini pdf dosyalarına dönüştürün


VBA ile çoklu Word belgelerini pdf dosyalarına toplu dönüştürün

Aşağıdaki VBA kodu, bir klasördeki tüm Word belgelerini aynı anda hızlı bir şekilde pdf dosyalarına dönüştürmenize yardımcı olur. Lütfen aşağıdaki işlemleri yapın.

1. Word'de, Ara Toplam + F11 tuşlarını açmak için Uygulamalar için Microsoft Visual Basic pencere.

2. içinde Uygulamalar için Microsoft Visual Basic Pencere, tıklayın Ekle > modül, ardından VBA kodunu Modül penceresine kopyalayın.

VBA kodu: Birden çok Word belgesini Word'deki pdf dosyalarına toplu olarak dönüştürün

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. Tuşuna basın. F5 kodu çalıştırmak için anahtar.

4. Bir Gözat iletişim kutusu açılır, lütfen pdf dosyalarına dönüştüreceğiniz Word belgelerini içeren klasörü seçin ve OK düğmesine basın.

Ardından, seçilen klasördeki tüm Word belgeleri bir defada ayrı pdf dosyalarına dönüştürülür. Ekran görüntüsüne bakın:


Kutools for Word ile birden fazla Word belgesini pdf dosyalarına dönüştürün

VBA kodunun işlenmesi zorsa, deneyebilirsiniz Belgeleri dönüştür yarar Kutools for Word sorunu çözmek için.

Kutools for Word : 100'den fazla kullanışlı Word eklentisiyle, herhangi bir sınırlama olmaksızın denemek için ücretsiz 60 Gün.

1. tık Kutools Artı > Doc / Docx. Ekran görüntüsüne bakın:

2. içinde Belge Biçimi Dönüştürücü penceresi, aşağıdakileri yapmanız gerekir:

2.1) içinde pdf'ye dönüştüreceğiniz belgeleri içeren klasörü seçin. Kaynak dosya klasörü Bölüm;
2.2 Seçin Docx'i pdf'ye dönüştürün itibaren Biçim Dönüştürme açılır liste;
2.3) Varsayılan olarak, Hedef yol, kaynakla aynı kutusu işaretlenmiştir. Dönüştürülen tüm pdf dosyalarını aynı klasöre yerleştirmek istiyorsanız, bu seçeneği seçili bırakın;
Pdf dosyalarını ve kaynak belgeleri ayırmak isterseniz, işaretini kaldırmanız gerekir. Hedef yol, kaynakla aynı kutusuna, pdf dosyalarını kaydetmek için yeni bir klasör seçin. Şuraya kaydet Kutu;
2.4) Başlama buton. Ekran görüntüsüne bakın:

3. Ardından, size kaç belgenin başarıyla dönüştürüldüğünü söyleyen bir iletişim kutusu açılır, OK düğmesine basın ve kapatın Belge Biçimi Dönüştürücü pencere.

Artık tüm .docx biçimli belgeler pdf dosyalarına dönüştürülüyor.

Bu yardımcı programı ücretsiz olarak denemek istiyorsanız, lütfen şu adrese gidin: yazılımı ücretsiz indirin önce ve sonra yukarıdaki adımlara göre işlemi uygulamaya gidin.

En İyi Ofis Üretkenlik Araçları

Kutools for Word - Over ile Kelime Deneyiminizi Yükseltin 100 Dikkat Çekici Özellikler!

🤖 Kutools Yapay Zeka Asistanı: Yazılarınızı AI ile dönüştürün - İçerik Oluştur  /  Metni Yeniden Yaz  /  Belgeleri Özetleyin  /  Bilgi İçin Arayın Belgeye dayalı, hepsi Word'de

📘 Belge Ustalığı: Sayfaları Böl  /  Belgeleri Birleştir  /  Seçimi Çeşitli Formatlarda Dışa Aktar (PDF/TXT/DOC/HTML...)  /  PDF'ye Toplu Dönüştürme  /  Sayfaları Görüntü Olarak Dışa Aktar  /  Aynı Anda Birden Çok Dosyayı Yazdırma...

İçerik Düzenleme: Toplu Bul ve Değiştir Birden Çok Dosyada  /  Tüm Resimleri Yeniden Boyutlandır  /  Tablo Satırlarını ve Sütunlarını Yer Değiştirme  /  Tabloyu Metne Dönüştür...

🧹 Zahmetsiz Temizlik: Uzaklaşın Ekstra Alanlar  /  Bölüm Sonları  /  Tüm Başlıklar  /  Metin kutuları  /  Köprüler  / Daha fazla sökme aleti için sayfamıza gidin Grubu Kaldır...

Yaratıcı Ekler: Ekle Bin Ayırıcı  /  Onay Kutuları  /  Radyo Düğmeleri  /  QR Code  /  Barkod  /  Çapraz Çizgi Tablosu  /  Denklem Başlığı  /  Görüntü Başlık  /  Tablo başlığı  /  Çoklu Resimler  / Daha fazlasını şurada keşfedin: Grup Ekle...

🔍 Hassas Seçimler: Nokta tespiti belirli sayfalar  /  tablolar  /  şekiller  /  başlık paragrafları  / Gezinmeyi şununla geliştirin: Daha Özellikleri seçin...

Yıldız Geliştirmeleri: Herhangi bir konuma hızla gidin  /  tekrarlanan metni otomatik olarak ekle  /  belge pencereleri arasında sorunsuzca geçiş yapın  /  11 Dönüşüm Aracı...

👉 Bu özellikleri denemek ister misiniz? Kutools for Word şunları sunar: 60 günlük ücretsiz deneme, hiçbir sınırlama olmaksızın! ????
 
Comments (36)
Rated 5 out of 5 · 3 ratings
This comment was minimized by the moderator on the site
Just found this, very helpful. Also thanks for the suggested mods above. I am struggling with the following:

If ((Right(xFileName, 4)) <> ".doc" Or Right(xFileName, 4) <> ".docx") Then


It seems to ask to do the conversion if it's not a doc or docx? (Leaving aside that, I think, for docx it should be last 5 chars, not 4?) Anyway,
This comment was minimized by the moderator on the site
the code stopped. I clicked debug. code below was highlighed yellow

Please, any assistance? thank you

Documents.Open Filename:=xFolder & xFileName, _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto, XMLTransform:=""
This comment was minimized by the moderator on the site
Thank you for this. It has just saved me so much time and provided education. I will peruse your site for more top tips.
Thank you again. Brilliant quick fix. One does have to ask, why do MS make such things so impossible to find in their products.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Здравствуйте! Огромное спасибо за модуль! Но есть проблема, у меня куча папок и в каждой папке больше двухсот файлов с разными именами.. Можно ли сделать так чтобы ваш модуль сохранял файлы в PDF не под номерами 1,2,3... и т.д, а под своими собственными именами файлов!? Помогите пожалуйста, и я буду молиться за вас ВЕЧНО!!))
This comment was minimized by the moderator on the site
Hi Егор,
I don't quite understand your question. After converting the file using the VBA code, the name of the PDF file is the same as the name of the Word file.
This comment was minimized by the moderator on the site
Здравствуйте! Большое спасибо вам, за то что вы есть! Спасибо за код он почти идеальный, но ОЧЕНЬ прошу Вас помочь с одним нюансом... Мне Очень важно чтоб ваш макрос сохранял в PDF не под номерами 1.2.3 и т.д, а брал название вордовского файла и сохранял под ним. У меня сто папок и в каждой по 251 файл со своим собственным названием... Мне это Очень нужно, пожалуйста помогите!?????.....
This comment was minimized by the moderator on the site
The VBA macro worked like a charm! :D
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi Myles,
Thank you for your feedback.
This comment was minimized by the moderator on the site
Hello is there a way to select a different output folder and not the original folder?

thank you
This comment was minimized by the moderator on the site
Hi Vincent,
Please try the following VBA code. After running the code, an Open window pops up, please select a folder containing the douments you want to convert, in the second popping up Save PDF files in window, select a folder to save the PDF files.

Sub ConvertWordsToPdfs()
'Updated by Extendoffice 20220805
  Dim xIndex As String
  Dim xDlg As FileDialog, xSaveDlg As FileDialog
  Dim xFolder As Variant, xSaveFolder As Variant
  Dim xNewName As String
  Dim xFileName As String
  On Error Resume Next
  Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
  xDlg.Title = "Open"
  xDlg.ButtonName = "Open"
  If xDlg.Show <> -1 Then Exit Sub
  xFolder = xDlg.SelectedItems(1) + "\"
  xFileName = Dir(xFolder & "*.*", vbNormal)
  Set xSaveDlg = Application.FileDialog(msoFileDialogFolderPicker)
  xSaveDlg.Title = "Save PDF files in"
  xSaveDlg.ButtonName = "Save"
  If xSaveDlg.Show <> -1 Then Exit Sub
  xSaveFolder = xSaveDlg.SelectedItems(1) + "\"
  Application.DisplayAlerts = wdAlertsNone
  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:=xSaveFolder & 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 wdSaveChanges
      End If
      xFileName = Dir()
  Wend
  Application.DisplayAlerts = wdAlertsAll
  Set xDlg = Nothing
  Set xSaveDlg = Nothing
End Sub
This comment was minimized by the moderator on the site
The code does not convert my Word files
This comment was minimized by the moderator on the site
This code is amazing and fast but if there is a link in the Doc file it will open a window stating there may be information linked to another file apply these changes? and then another asking to save as. Is there a way to add to the code to automatically do these steps for me? Out of ~800 there are ~40 and I must be present and do this every time.
thank you
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi Vincent,
The following VBA code can do you a favor. Please give it a try. Thank you for your feedback.

Sub ConvertWordsToPdfs()
'Updated by Extendoffice 20220805
  Dim xIndex As String
  Dim xDlg As FileDialog
  Dim xFolder As Variant
  Dim xNewName As String
  Dim xFileName As String
  On Error Resume Next
  Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
  If xDlg.Show <> -1 Then Exit Sub
  xFolder = xDlg.SelectedItems(1) + "\"
  xFileName = Dir(xFolder & "*.*", vbNormal)
  Application.DisplayAlerts = wdAlertsNone
  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 wdSaveChanges
      End If
      xFileName = Dir()
  Wend
  Application.DisplayAlerts = wdAlertsAll
End Sub
This comment was minimized by the moderator on the site
Вот тут во втором условии надо 4 заменить на 5:
If ((Right(xFileName, 4)) <> ".doc" Or Right(xFileName, 5) <> ".docx") Then
Для исключения проблемы наличия точек можно сделать так:
xIndex = InStr(xFileName, ".doc") + 1
Ну и про советы других товарищей не забыть ;)

This comment was minimized by the moderator on the site
Thank you so much! Saved me so much time!
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