Sub ConvertDocxToPdf() Dim folderPath As String Dim fileName As String Dim objWord As Object Dim objDoc As Object ' Specify the folder containing your DOCX files folderPath = "C:\docx\" ' Get the first DOCX file in the folder fileName = Dir(folderPath & "*.docx") ' Create a Word application instance Set objWord = CreateObject("Word.Application") objWord.Visible = False ' Loop through each DOCX file in the folder Do While fileName <> "" ' Open the DOCX file Set objDoc = objWord.Documents.Open(folderPath & fileName) ' Create the PDF file objDoc.ExportAsFixedFormat OutputFileName:=folderPath & Replace(fileName, ".docx", ".pdf"), _ ExportFormat:=17 ' Close the DOCX file objDoc.Close SaveChanges:=False ' Get the next DOCX file in the folder fileName = Dir Loop ' Close the Word application objWord.Quit Set objWord = Nothing Set objDoc = Nothing ' Display a message when done MsgBox "Conversion completed." End Sub